在调试一个PHP程序时返回这样的错误:
Notice: Only variable references should be returned by reference in /www/include/template.class.php 43
追踪至该行:
42 function &fetch ( $tplname ) {
43 return $this->display ( $tplname, 0 );
44 }
百思不得其解,便从网上找来一个答案:
it is just saying it doesn't like returning the value from the function... you could always put it in a var and return that.(from lig@codewalkers.com ::Feb 2 2006 06:25 PM)
于是将该函数改为:
42 function &fetch ( $tplname ) {
43 $v = $this->display ( $tplname, 0 );
44 return $v;
45 }
再测试,问题解决。
在PHP编程中,遇到'Only variable references should be returned by reference'错误时,通过将返回值赋给变量再返回,成功解决了问题。本文详细介绍了错误原因及解决方案。

被折叠的 条评论
为什么被折叠?



