Home Tutorial Php Phpbasics Tutorial PHP Variable Functions

 
 

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

 

 

Advertisement

Related Tags for PHP Variable Functions:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 2, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com