1

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.

AlexP
  • 9,906
  • 1
  • 24
  • 43
user2931829
  • 15
  • 1
  • 3
  • Have you created the Variables before? – demonking Oct 29 '13 at 11:36
  • duplicate http://stackoverflow.com/questions/12322811/call-time-pass-by-reference-has-been-removed http://stackoverflow.com/questions/13553698/call-time-pass-by-reference-has-been-removed http://stackoverflow.com/questions/18684222/call-time-pass-by-reference-has-been-removed-error ... – Fabien Sa Oct 29 '13 at 11:39
  • possible duplicate of [PHP 5.4 Call-time pass-by-reference - Easy fix available?](http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available) – Fabien Sa Oct 29 '13 at 11:40

1 Answers1

5

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.

Nelson
  • 49,283
  • 8
  • 68
  • 81
  • +1 The [PHP documentation](http://php.net/manual/en/language.references.pass.php) says "As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And **as of PHP 5.4.0**, call-time pass-by-reference was removed, so using it will raise a fatal error. – AlexP Oct 29 '13 at 11:43