开发者

fatal error Function name must be a string

开发者 https://www.devze.com 2023-01-23 04:54 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消