To call a function from a string stored in a variable, use $func.
The syntax is as follows
$func=’anyFunctionName’;
Example
The PHP code is as follows
<!DOCTYPE html>
<html>
<body>
<?php
function hello(){
echo "Calling hello method."."<br>";
}
function welcome(){
echo "Calling welcome method."."<br>";
}
$func = 'hello';
$func();
?>
</body>
</html>Output
This will produce the following output
Calling hello method.