Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

php - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...