Reputation: 69
I get this error:
Only variables should be assigned by reference
on this line:
$sum = &self::genchksum10($isbn);
of my function:
public function validateten($isbn) {
$isbn = trim($isbn);
$chksum = substr($isbn, -1, 1);
$isbn = substr($isbn, 0, -1);
if (preg_match('/X/i', $chksum)) { $chksum="10"; }
$sum = &self::genchksum10($isbn);
if ($chksum == $sum){
return 1;
}else{
return 0;
}
}
I’m not really sure what’s wrong with it. Any help would be greatly appreciated.
Upvotes: 1
Views: 394
Reputation: 29975
You are trying to create a reference to the result of a function. That's not possible in PHP.
Just remove the &
Upvotes: 0
Reputation: 146302
An object cannot reference itself with a reference (&
).
Try without it:
$sum = self::genchksum10($isbn);
Upvotes: 4