Fix – Methods with the same name as their class

PHP4-style constructors still work on PHP7, they are just been deprecated and they will trigger a Deprecated warning.

What you can do is define a __construct method, even an empty one, so that the php4-constructor method won’t be called on a newly-created instance of the class.

class foo{
    function foo(){
        // Constructor's functionality here, if you have any.
    }
}

Change to:

class foo{
    function __construct(){
        // Constructor's functionality here, if you have any.
    }
}

Revisions

Tags: ,

No comments yet.

Leave a Reply