Sunday, April 4, 2010

Functions

Create a PHP Function

Syntax:


(click image to view)

If you want to give a name to the function, you must give a name that reflects what function does. It can be start with a letter / underscore (and NOT a number). See the example below:


(click image to view)

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

My name is Abdul Razzaq
############################################################



Adding Parameters into Functions

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


(click image to view)

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

My name is Abdul Razzaq Ali.
My sister's name is Aisyah Ali.
My brother's name is Zainal Ali.
############################################################



Return a Value


(click image to view)

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

5 x 6 = 30
############################################################

No comments:

Post a Comment