How to create function and call function inside another function in PHP
A function is a block of statements that can be used repeatedly in a program. A function will not execute automatically when a page loads. A function will be executed by a call to the function.
// define function in php
function sayHello()
{
echo "Hello World !";
}
sayHello();
echo "<br>";
// Function calling another function
function init()
{
greet();
echo "<br>";
calculate();
}
function greet()
{
echo "This is from PHP";
}
function calculate()
{
echo $sum = 10 + 12;
}
init();

0 comments
Post a Comment