0

I have to work with some legacy PHP 4 code. I have PHP 5.4 installed on my machine and getting this nasty error:

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

I already found a solution/fix, but it requires changes in existing code. My questions is - is there a way to IGNORE this error? I don't want to fix it (as it requires a LOT of code changes), but ignore and do my work. I am looking for some kind of "config" change in PHP/Apache, so I do not need to mess with legacy code.

Yes, yes... I know that is not a good practice, but unfortunately that is what I need right now.

Kamil Kłys
  • 1,907
  • 3
  • 18
  • 30
  • possible duplicate of [How do I catch a PHP Fatal Error](http://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-error) – kero Apr 12 '15 at 13:19

1 Answers1

3

A fatal error cannot be stopped (this is why they are called fatal) - not even by stuff like set_error_handler.

You will have to change your code.

But fixing it should not be a huge problem, because the error is caused by & in function calls:

function test($param) { }
test(&$test);      // fatal error

function test(&$param) { }
test($test);       // no error

Documentation:

  • 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.

So to make a (very) nasty workaround, you could install PHP 5.3.0 :(

Marc
  • 3,683
  • 8
  • 34
  • 48
  • Too bad it can't be done by some kind of config change. Anyway, thanks for making it clear! I guess I would have to downgrade to 5.3, as removing pass-by-reference caused existing code to not work properly. – Kamil Kłys Apr 12 '15 at 15:31