• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Function From Variable

BananaMaster

New Member
Ok,

So lets say I have a variable in PHP called $test123 and it's defined to "echo Test1234;";

Is it possible to run that command from that variable...
 
Yep, eval will work, but it's suitability is questionable for executing anonymous functions ...

PHP:
<?php
/** MUCH preferred **/
$test = create_function( '', 'echo "Test 1234\r\n";' );
$test();

/** OR **/
function test( )
{
	echo "Test 1234\r\n";		
}
$test = 'test';
$test( );

?>
 
Back
Top