Function Samples
Sample :
function displayMyName()
{
echo "Juan Dela Cruz";
}
displayMyName()
?>
Sample use of a function in a PHP script.
function displayMyName()
{
echo "Juan Dela Cruz";
}
echo "Hello World! “;
echo “My name is “;
displayMyName()
echo “That’s right, “;
displayMyName();
echo ” is my name.”;
?>
The output of the sample would be:
Hello World!
My name is Juan Dela Cruz.
That’s right, Juan Dela Cruz is my name.
More on functions in the next post as we discuss further the possibilities of these powerful ready made blocks of code.
Filed under: Basic Programming, Sample Code by Avatar
