Home >Backend Development >PHP Problem >How to dynamically call functions in php
How to dynamically call a function in php: first define a function; then assign the function name or string to a variable; finally use the variable name instead of the function name to dynamically call the function.
How to dynamically call functions in php:
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
The detailed code is as follows:
<?php function addition ($a, $b){ echo ($a + $b), "\n"; } $result = "addition"; $result (3,6); ?>
Related video recommendations: PHP programming from entry to proficiency
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!