Changes

Jump to: navigation, search

PHP Functions

792 bytes added, 19:57, 31 May 2007
How to Write a PHP Function
== How to Write a PHP Function ==
 
the first step in creating a PHP function is provide a name by which you will reference the function. Naming conventions for PHp functions are the same as those for variables in that they must begin with a letter or an underscore and must be devoid of any kind of white space or punctuation. You must also take care to ensure that your function name does not conflict with any of the PHP built in functions.
 
PHP functions are created using the ''function'' keyword followed by the name and, finally a set of parentheses. The body of the function (the script that performs the work of the function) is then enclosed in opening and closing braces.
 
The following example function simply output a string when it is called:
 
<pre>
<?php
function sayHello()
{
print "Hello";
}
?>
</pre>

Navigation menu