Heim  >  Artikel  >  php教程  >  解决Fatal error: Call-time pass-by-reference has bee

解决Fatal error: Call-time pass-by-reference has bee

WBOY
WBOYOriginal
2016-06-06 20:09:361842Durchsuche

今天在使用PHP 5.4.15 版本时遇到这个错误: Fatal error : Call-time pass-by-reference has been removed in /opt/lampstack-5.4.15-0/apps/lixiphp/htdocs/function.inc on line 161 产生这个错误原因是在PHP函数语句中使用来引用变量。比如: foo($varia

今天在使用PHP 5.4.15 版本时遇到这个错误:

Fatal error: Call-time pass-by-reference has been removed in /opt/lampstack-5.4.15-0/apps/lixiphp/htdocs/function.inc on line 161

产生这个错误原因是在PHP函数语句中使用&来引用变量。比如:

foo(&$variable);

实际上,这样用法在PHP 5.3 中就会有提示,只是之前的仅仅会提示Deprecated而已。

简单一句话,调用函数时不需要传递引用变量。

正确用法

函数语句中不需要使用引用变量。
myFunc($var);//Call myFunc
function myFunc(&$arg) { do something... }???? 

错误用法

myFunc(&$arg);//Call myFunc 
function myFunc($arg) { do something... }? 

屏蔽错误显示

error_reporting(0); 
ini_set('display_errors', 'off');

运行时环境:

php-5.4.15 使用PHP 5.4.15 版本

(...)
Read the rest of 解决Fatal error: Call-time pass-by-reference has been removed (9 words)


© lixiphp for LixiPHP, 2013. | Permalink | No comment | Add to del.icio.us
Post tags: PHP 5.4, reference. 引用

Feed enhanced by Better Feed from Ozh

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn