Deprecation Warning: Methods with the Same Name as Their Class
In PHP, methods with the same name as their class will no longer be constructors in future versions. This issue arises when the constructor method's name matches the class name.
Error Message:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; TSStatus has a deprecated constructor in ... on line 10
Affected Code:
<code class="php">class TSStatus { ... public function TSStatus($host, $queryPort) ... }</code>
Solution:
Replace the TSStatus method with __construct.
<code class="php">class TSStatus { ... public function __construct($host, $queryPort) ... }</code>
The above is the detailed content of Does PHP Deprecate Methods with Class Name Constructors?. For more information, please follow other related articles on the PHP Chinese website!