ELE
ELE

Reputation: 33

PHP Fatal error: Call-time pass-by-reference has been removed

"Fatal error: Call-time pass-by-reference has been removed in .... on line 62"

Line 62-65:

$scCon = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scCon) {
$scsuccess=1;
}

Help! How do I fix this?

Upvotes: 1

Views: 4474

Answers (3)

Jan Vorisek
Jan Vorisek

Reputation: 549

Just remove the leading & in $errno and $errstr.

$scCon = fsockopen("$scip", $scport, &$errno, &$errstr, 30);

will become

$scCon = fsockopen("$scip", $scport, $errno, $errstr, 30);

As of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.

Upvotes: 0

John Smith
John Smith

Reputation: 1110

Call-time pass-by-reference has been removed

$scCon = fsockopen("$scip", $scport, $errno, &$errstr, 30);
if(false === $scCon) {
    echo "$errstr ($errno)";
}

Upvotes: 0

RiggsFolly
RiggsFolly

Reputation: 94682

You are supposed to specify the requirement for a reference when the function is defined, not when you call the function.

So amend the function call to

fsockopen("$scip", $scport, $errno, $errstr, 30);

If the function has been defined as requiring a reference it will turn your call time parameters into references and if it does not require a reference it will not

Upvotes: 1

Related Questions