Incompatibility errors with after PHP 7.0

Incompatibility errors with after PHP 7.0

The only errors that may occur are due to codes used in events, libraries, and methods that are not compatible with PHP 7.0. These errors must be corrected manually.


1 - Short open tags

The short_open_tag directive tells PHP whether the abbreviated form (<? ?>) of the PHP opening tag is allowed.

Regardless of the php version, you need to check in php.ini if short_open_tags is enabled.

Solution 1:
Change the opening tag of php to (<?php ?>)
Solution 2:
Change the short_open_tags directive in php.ini:

short_open_tags = On


2 - New objects cannot be assigned by reference

The result of the new statement can no longer be assigned to a variable by reference:
<?php
class C {}
$c =& new C;
?>

The example above will print in PHP 5:
              Deprecated: Assigning the return value of new by reference is deprecated in /tmp/test.php on line 3

The above example will print in PHP 7:
              Parse error: syntax error, unexpected 'new' (T_NEW) in /tmp/test.php on line 3

Solution:
              Remove reference (&) from assignment:

<?php
class C {}
$c = new C;
?>


3 - PHP 4 Style Constructors

PHP 4 style constructors (methods that have the same name as the class where they are defined) are deprecated, and will be removed in the future. PHP 7 will issue E_DEPRECATED if a PHP 4 constructor is the only constructor defined in the class. Classes that implement the __construct () method are not affected.

<?php
class foo {
    function foo() {
        echo 'Eu sou um construtor';
    }
}
?>

The above example will print:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in example.php on line 3


4 - Static calls to non-static methods

Static calls to methods that have not been declared as static are deprecated, and can be removed in the future.

<?php
class foo {
    function bar() {
        echo 'Eu não sou estático!';
    }
}

foo::bar();

?>

The above example will print:

Deprecated: Non-static method foo::bar() should not be called statically in - on line 8
I am not static!


For more information:

PHP 7.0 new features
  - PHP 7.0 deprecated features


Source: http://php.net

    • Related Articles

    • Install ScriptCase PHP 7.0 on a XAMPP on Linux

      Xampp Installation Using PHP 7.0 XAMPP It allows you to easily install Apache on your own computer, regardless of your operating system (Linux, Windows, MAC or Solaris). First you have to proceed to download XAMPP PHP ...
    • PHP error level - error_reporting

      The error_reporting directive in php.ini defines the levels of errors that PHP will report, the levels of errors are:   Errors and Logging Value Constant Description Note 1 E_ERROR (integer) Fatal run-time errors. These indicate errors that can not ...
    • Install ScriptCase PHP 7.3 on a XAMPP in Linux

      Xampp Installation Using PHP 7.3 XAMPP It allows you to easily install Apache on your own computer, regardless of your operating system (Linux, Windows, MAC or Solaris). First you have to proceed to download XAMPP PHP ...
    • PHP extensions

      In php.ini there is the following extensions: If you would like to use one of those extension, for example MySQL, do the following: Remove the character ";" at the beginning of the extension Ex: extension = php_mysql.dll Save the file and restart the ...
    • Updating Scriptcase's PHP

      Currently, the installation of Scriptcase 9.x comes with version 7.0.14 of PHP, unfortunately, this version has a compatibility problem with the new version of authentication of MySQL 8.0, so it is necessary to perform the PHP update so the ...