致命错误函数名称必须是字符串 [英] fatal error Function name must be a string

查看:111
本文介绍了致命错误函数名称必须是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢回答我最后一个问题的人

thanks to the folks who answered my last question

我不断收到此错误:函数名称必须是第4行/home/pulsergf/public_html/these/vars.php中的字符串

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]";');
?>

所以它需要在数组中选择BOUGHT和SOLD对,但是我一直收到此错误.谢谢

so it needs to choose the pair in the array for BOUGHT and SOLD but i keep getting this error. thanks

推荐答案

您不需要define前面的$.

为什么?

当您在define之前加上$并在(...)中添加一些参数时,它将被解释为

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.

这篇关于致命错误函数名称必须是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆