PHP 5.4调用时间传递引用 - 这里很容易解决?

时间:2013-10-29 11:34:49

标签: php

我在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专家。

1 个答案:

答案 0 :(得分:5)

只需删除这样的前导&

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

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