Deprecated features in PHP 7

PHP Updates & Compatibility

June 18, 2017

Deprecated features in PHP 7

Even though PHP 7.0 is a new major version, efforts have been made to make migration as painless as possible. This release focuses mainly on removing functionality deprecated in previous versions and improving language consistency.

PHP 4 style constructors

<?php
class foo {
    function foo() {
        echo 'I am the constructor';
    }
}
?>

The above example will output:

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

Static calls to non-static methods

Static calls to methods that are not declared static are deprecated, and may be removed in the future.

<?php
class foo {
    function bar() {
        echo 'I am not static!';
    }
}

foo::bar();
?>

The above example will output:

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

password_hash() salt option

The salt option for the password_hash() function has been deprecated to prevent developers from generating their own (usually insecure) salts. The function itself generates a cryptographically secure salt when no salt is provided by the developer – therefore custom salt generation should not be needed.

capture_session_meta SSL context option

The capture_session_meta SSL context option has been deprecated. SSL metadata is now available through the stream_get_meta_data() function.

LDAP deprecations

The following function has been deprecated:
1. ldap_sort()

In the next article I will discuss about PHP 7 New features.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

Tags

featuresPHP 7

Related Posts

Many new updates happened for Android developers lately after Google I/O. Initially there was no restriction on some features but now.
phpMyAdmin is a web-based database management tool that you can use to view and edit the MySQL databases on your EC2 instance.
Title attribute can be helpful to expand on the meaning of your navigation label and give your users more context You can provide to the link.