PHP Variable functions are used to assign a function's name to a variable. In this current PHP tutorial, we will study about that, how to declare php variable functions, how to assign, how to call via a variable and how to pass values.
PHP Variable functions are used to assign a function's name to a variable. In this current PHP tutorial, we will study about that, how to declare php variable functions, how to assign, how to call via a variable and how to pass values.PHP Variable Functions:
Learn PHP Variable Function means that if a variable name has a format like this $var(), PHP will consider this as a variable function and will look for a function with a name which is assigned to it, and will try to execute it.
This variable function does not work with echo(), print(), unset() etc language constructs.
PHP Example:/strong>
<?php
function
fun(){
echo "This is an example";}
function
disp($var){ echo "<br/>Value is:".$var;}
$f
='fun';$f
();$f
='disp';$f
('New Val');?>
Output:
This is an example