How to Create a PHP Function?
By Abhijit Paul
How to Create a PHP Function?????
Teacher SiliconIndia replied to Abhijit Paul Wednesday, March 17, 2010
Hi Abhijit,
A function will be executed by a call to the function.
Syntax
function functionName()
{
code to be executed;
}
PHP function guidelines:
* Give the function a name that reflects what the function does
* The function name can start with a letter or underscore (not a number)
Example
A simple function that writes my name when it is called:
<html>
<body>
<?php
function writeName()
{
echo "Harvi Sachar";
}
echo "My name is ";
writeName();
?>
</body>
</html>
Output:
My name is Harvi Sachar