Loading video...
Introduction to Functions
- A function is a group of PHP statements that can be executed on request by other PHP code using what’s known as a function call .
- When reaching a function call, PHP halts execution of the current script, executes the function’s section of code, and then returns to executing the original script.
- A function call is made by typing name of the function followed by a pair of parentheses.
- Function arguments are expressions that can be 'passed' to a function by placing them in a comma-separated list between the parentheses of a function call.
- Functions are themselves expressions and thus have a value. The value of a function is called its return value , and this value is 'returned' to the calling script.
- Functions can be chained together by using the return value of one function as an argument to another.
- php.net provides documentation, via a function reference , for all of the built-in functions PHP makes available to programmers. The documentation provides function prototypes , which are descriptions of the arguments a particular function accepts along with what type of data value it returns.
- Functions in PHP can be defined to take optional arguments . In the php.net function reference, optional arguments are denoted in a function’s prototype by placing them within pairs of square brackets.
- Additonal Resources:
Introduction to Functions
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
- Intro
- Lesson Overview
- What are Functions?
- Function Calls
- Return Values
- Function Chaining
- PHP.net Function Reference
- Optional Function Arguments
- String Functions
- Array Functions
- count()
- in_array() and array_key_exists()
- sort() and ksort()
- Example: count() and in_array()
- Example: array_key_exists()
- Example: sort() and ksort()
- Date & Time Functions
- date() and time()
- getdate()
- mktime()
- Date & Time Functions
- Example: date() and time()
- Example: getdate()
- Example: mktime()
- Homework Challenge #1
- Homework Challenge #1 (Cont.)
- Homework Challenge #2
- Homework Challenge #2 (Cont.)
- Homework Challenge #2 (Cont.)
- Homework Challenge #3

































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview