The method of dynamically calling functions in php is: 1. Define a function, such as [function addition($a,$b)]; 2. Assign the function name (string) to a variable, such as [ $result="addition"]; 3. Use variable names instead of function names to dynamically call functions.
Steps to dynamically call functions:
(Recommended tutorial: php tutorial)
1 , define a function;
2. Assign the function name (string) to a variable;
3. Use the variable name instead of the function name to dynamically call the function.
Code implementation:
<?php function addition ($a, $b){ echo ($a + $b), "\n"; } $result = "addition"; $result (3,6); ?>
The above is the detailed content of How to dynamically call functions in php. For more information, please follow other related articles on the PHP Chinese website!