Home Tutorial Php Phpbasics Tutorial PHP Variable Functions

 
 

PHP Variable Functions
Posted on: March 2, 2010 at 12:00 AM
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
Value is:New Val

 

 

Related Tags for PHP Variable Functions:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.