HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |
| |||||||||||
PHP Functions
PHP FunctionsThe real power of PHP comes from its functions. In PHP, there are more than 700 built-in functions. PHP Built-in FunctionsFor a complete reference and examples of the built-in functions, please visit our PHP Reference.PHP FunctionsIn this chapter we will show you how to create your own functions. To keep the script from being executed when the page loads, you can put it into a function. A function will be executed by a call to the function. You may call a function from anywhere within a page. Create a PHP FunctionA function will be executed by a call to the function. Syntax
PHP function guidelines:
ExampleA simple function that writes my name when it is called:
Output:
PHP Functions - Adding parametersTo add more functionality to a function, we can add parameters. A parameter is just like a variable. Parameters are specified after the function name, inside the parentheses. Example 1The following example will write different first names, but equal last name:
Output:
Example 2The following function has two parameters:
Output:
PHP Functions - Return valuesTo let a function return a value, use the return statement. Example
Output:
|
|||||||||||
© 2011 d4download.orgfree, All Rights Reserved.
Design created by diljith d4download veriosn 2.0
HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |