fatal error Function name must be a string
thanks to the folks who answered my last开发者_如何学编程 question
i keep getting this error: Function name must be a string in /home/pulsergf/public_html/these/vars.php on line 4
<?
$array = array('555', '666', 'aaa', 'bbb', '777', '888');
$rand_index = mt_rand(0, count($array) / 2 - 1) * 2;
$define('BOUGHT','echo "$array[$rand_index]";');
$define('SOLD','echo "$array[$rand_index+1]";');
?>
so it needs to choose the pair in the array for BOUGHT and SOLD but i keep getting this error. thanks
use define
instead of $define
$define()
indicates a variable function, which means it takes the string value of $define
and tries to call the function with the same name as that string.
You don't need a $
in front of define
.
Why?
When you precede define
with $
followed by a few parameters within (...)
, it is interpreted as a variable function. Since the variable $define
is not defined it becomes effective equivalent to calling a function without the function name.
精彩评论