Saturday, March 20, 2010

PHP - Functions

-----------------------------------------------------------------------------------------------------------------------------------
Put your script into a function to keep the browser from executing the script when the page loads. The function will be executed by a call to the function.
-----------------------------------------------------------------------------------------------------------------------------------

Create PHP Function

More about PHP function:
  • Give the function a name that reflects what the function does.
  • The function name can start with a letter or underscore (but NOT a number).
For instances:


############################################################
The Output:
My name is Abdul Razzaq
############################################################


PHP Functions - Adding Parameters

The following example will write different first name, but equal last name:

############################################################
The Output:

My name is Mohd Fairus Ali

My sister's name is Ain Ali
My brother's name is Mohd Faiz Ali
############################################################


PHP Functions - Return values

For instances:


############################################################
The Output: 5 + 10 = 15
############################################################

0 comments:

Post a Comment