Search code examples
phpversionupgradesmarty

Migrate php codes from 5.4 to php 7


Currently, I'm working with php 5.4, and would like to move to 7 or 7.2. While running my code on server php 7.2, its throws the syntax error, unexpected 'new' (T_NEW). It depends upon the assigned class with & operator.

I used this kind of code overall project. It not possible to remove all the functionalities.

$instance =& new Configure();

May I achieve running my project under php 7.2 without removing the assigning operator?


Solution

  • Since PHP 5, new returns a reference automatically, so using =& in this context is deprecated and produces an E_DEPRECATED message in PHP 5.3 and later, and an E_STRICT message in earlier versions. As of PHP 7.0 it is syntactically invalid.

    PHP references

    So you have to change your code.