Make a downgrade to PHP from 5.4 to 5.3 in Centos 6.9

1

We recently need to update the version of mysql and when installing the repos and proceed to the installation of mysql these repos updated me in turn the server php affecting the functionality of the system that we have running. After acting normally now throws this error:

  

Fatal error: Call-time pass-by-reference has been removed in   / location / de / carpetaraiz Code line ####

So we are in need of a downgrade to the version that was previously running. If someone can give me a hand and guide me on how to do it, I would be infinitely grateful.

    
asked by Luis Alfredo Serrano Díaz 10.05.2018 в 12:13
source

1 answer

1

The indicated error is due to one of the incompatibilities of versions 5.3 and 5.4, you can see a list here , specifically the incompatibility is:

  

The step by reference in call time has been eliminated.

In the documentation of step by reference we found a note that does not indicate the following:

  

Note: There is no reference sign in a call to a function - only in the definition of the function. The definitions of functions alone are sufficient to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" (pass by reference in call time) is obsolete when you use & in foo (& $ a); As of PHP 5.4.0, the step by reference call time has been eliminated, so its use will emit a fatal error.

Summing up this means that the calls to functions passing variable as reference is obsolete, in PHP 5.3 a warning was issued and in 5.4 a fatal error. Example:

<?php
function foo(&$var)
{
    $var++;
}

$var = 1;

foo(&$var); // ERROR

foo($var); // Correcto

Also in the documentation we can see that you can only pass the following by reference:

  • Variables, that is, foo ($ a)
  • New statements, that is, foo (new foobar ())
  • References returned from functions

If only this is the error you have had when migrating from PHP 5.3.x to PHP 5.4.x, my recommendation is that you correct the code by removing the references, that is, by removing the & amp; (ampersand or et) before the variables in the functions.

    
answered by 10.05.2018 / 17:20
source