function php return code example
Example 1: return two variables php
function getXYZ()
{
return array(4,5,6);
}
list($x,$y,$z) = getXYZ();
// Afterwards: $x == 4 && $y == 5 && $z == 6
// (This will hold for all samples unless otherwise noted)
Example 2: how to define function in php
<?php
function writeMsg() {
echo "Hello world!";
}
writeMsg(); //call the function
?>
Example 3: execute function php
function functionName() {
//code to be executed;
}
functionName();