Variable function example : Dynamic Function « Functions « PHP






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

1.Calling Functions Dynamically
2.Calling a Function Dynamically
3.Calling Variable Functions
4.Calling a Function Dynamically
5.Creating Dynamic Functions
6.return the function name from a function call or calculation
7.Variable Function Names
8.Using a variable function determined by some input variable
9.String Manipulation
10.Using Arrays of Lambda Functions