![]() |
||||||||||||||||||||||
| Home --- Topics --- Articles --- Offers --- Register --- Contact us | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Did you know? if you register at Hamid School you can save up to 45% on hosting packages offered by Surreyhost.com . Don't miss out, every minute counts! Are you Confused? Click here to learn how to use hamid school PHP FunctionsThe real power of PHP comes from its functions. In PHP - there are more than 700 built-in functions available. PHP FunctionsIn this tutorial we will show you how to create your own functions. For a reference and examples of the built-in functions, please visit our PHP Reference. Create a PHP FunctionA function is a block of code that can be executed whenever we need it.
ExampleA simple function that writes my name when it is called:
Use a PHP FunctionNow we will use the function in a PHP script:
The output of the code above will be:
PHP Functions - Adding parametersOur first function (writeMyName()) is a very simple function. It only writes a static string. To add more functionality to a function, we can add parameters. A parameter is just like a variable. You may have noticed the parentheses after the function name, like: writeMyName(). The parameters are specified inside the parentheses. Example 1The following example will write different first names, but the same last name:
The output of the code above will be:
Example 2The following function has two parameters:
The output of the code above will be:
PHP Functions - Return valuesFunctions can also be used to return values. Example
The output of the code above will be:
Viewed:286
Did you know? if you register at Hamid School you can learn web programming and designing for free and also you can save up to 45% on hosting packages offered by Surreyhost.com . Don't miss out, every minute counts!
|
|
|||||||||||||||||||||
|
Sponsored by: Surreyhost.com Coded and designed by: Hamid Moudi HPLA |
||||||||||||||||||||||