Variable function example : Dynamic Function « Functions « PHP
- PHP
- Functions
- Dynamic Function
Variable function example
<?php
function foo() {
echo "In foo()<br>\n";
}
function bar( $arg = " ) {
echo "In bar(); argument was '$arg'.<br>\n";
}
$func = 'foo';
$func();
$func = 'bar';
$func( 'test' );
?>
Related examples in the same category