PHP 5.4调用时间传递引用

编程入门 行业动态 更新时间:2024-10-12 14:23:01
PHP 5.4调用时间传递引用 - 这里很容易解决?(PHP 5.4 Call-time pass-by-reference - Easy fix here?)

我有这个错误消息与Centos 5.9,PHP 5.4和较旧的PHP程序扩展(typo3 CMS)。

PHP致命错误:已在第279行的class.tx_spscoutnetcalendar_pi1.php中删除了调用时传递引用

这是模拟php代码的功能:

// ********* Start XML code ********* // get XML data from an URL and return it function fetchCalendarData($xmlUrl,$timeout) { $xmlSource=""; $url = parse_url($xmlUrl); $fp = fsockopen($url['host'], "80", &$errno, &$errstr, $timeout); if ($fp) { fputs($fp, "GET ".$url['path']."?".$url['query']." HTTP/1.1\r\nHost: " . $url['host'] . "\r\n\r\n"); while(!feof($fp)) $xmlSource .= fgets($fp, 128); } // strip HTTP header if ($pos = strpos($xmlSource,"<?xml")) { // this has to be the first line $xmlSource = substr($xmlSource, $pos); } else { $xmlSource=""; } // I have no idea why, but at the end of the fetched data a '0' breaks the XML syntax and provides an // error message in the parser. So I just cut the last 5 characters of the fetched data $xmlSource = substr($xmlSource,0,strlen($xmlSource)-5); return $xmlSource; }

具体这一行279

$fp = fsockopen($url['host'], "80", &$errno, &$errstr, $timeout);

请帮忙,我不是php专家。

I have this error Message with Centos 5.9, PHP 5.4 and an older PHP program extension (typo3 CMS).

PHP Fatal error: Call-time pass-by-reference has been removed in class.tx_spscoutnetcalendar_pi1.php on line 279

This is analog the php code function:

// ********* Start XML code ********* // get XML data from an URL and return it function fetchCalendarData($xmlUrl,$timeout) { $xmlSource=""; $url = parse_url($xmlUrl); $fp = fsockopen($url['host'], "80", &$errno, &$errstr, $timeout); if ($fp) { fputs($fp, "GET ".$url['path']."?".$url['query']." HTTP/1.1\r\nHost: " . $url['host'] . "\r\n\r\n"); while(!feof($fp)) $xmlSource .= fgets($fp, 128); } // strip HTTP header if ($pos = strpos($xmlSource,"<?xml")) { // this has to be the first line $xmlSource = substr($xmlSource, $pos); } else { $xmlSource=""; } // I have no idea why, but at the end of the fetched data a '0' breaks the XML syntax and provides an // error message in the parser. So I just cut the last 5 characters of the fetched data $xmlSource = substr($xmlSource,0,strlen($xmlSource)-5); return $xmlSource; }

And specific this line 279

$fp = fsockopen($url['host'], "80", &$errno, &$errstr, $timeout);

Any help here please, i'm not a php expert.

最满意答案

只需删除前导&喜欢这个:

$fp = fsockopen($url['host'], "80", $errno, $errstr, $timeout);

变量仍然通过引用传递,但是您不需要使用&来表示从PHP 5.4开始。

Just remove the leading & like this:

$fp = fsockopen($url['host'], "80", $errno, $errstr, $timeout);

the variables are still passed by reference, but you don't need the & to indicate that from PHP 5.4 onwards.

更多推荐

本文发布于:2023-08-02 08:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1372733.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!