Forum : How to Create a PHP Function?
Brief description  about Online courses   join in Online courses
View Abhijit  Paul 's Profile

How to Create a PHP Function?

How to Create a PHP Function?????
Asked by Abhijit Paul | Mar 17, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
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
Mar 17, 2010