Web application under PHP7 reports error Methods with the same name

Methods with the same name as their class will not be constructors in a future version of PHP
The reason for this error is that PHP7 no longer supports constructors with the same class name and function name. Methods and construction methods uniformly use __construct(). Note that the horizontal color in __construct is two "_". For example, if the following writing method is used, PHP7 will report this error.

<?php  
class getIP {  
    function getIP($val) {
        echo 'IP:127.0.0.0.1';
    }
}
?>

Change it to the following method and you will not get an error.

<?php  
class getIP {  
    function __construct($val) {
        echo 'IP:127.0.0.0.1';
    }
}
?>

Guess you like

Origin blog.csdn.net/u010439874/article/details/132523868