What is User Defined Function (UDF) in PHP?
function in php : A UDF or User Defined Function in PHP can act as a procedure (void function) . A UDF must be declared with key word \’function\’ ,we can return statement or values if required .
To UnderstandUser Defined Function in PHP UDF lets take an example
<?php
function sayhi()
{
echo \"Hi!\";
echo \"Hello\";
}
sayhi();
?>
<?php
function addnum($x,$y)
{
return ($x+$y);
}
sayhi();
addnum(2,3);
///output will be 5
?>
Above are the two example of User Defined Function UDF in PHP in first example output returns statement while in other integer value.