In the latest version of PHP 7 you will face an error message as Methods with the same name as their class will not be constructors in a future version of PHP. So, this post is about how to fix Methods with the same name as their class will not be constructors in a future version of PHP.
Earlier version of PHP supports below codes
As PHP 7 does not support a simple tweak will fix this issue. To fix the issue you just need to add a constructor function as below
class foo
{
public function __construct()
{
echo ‘I am the constructor’;// same as earlier
}
public function foo()
{
echo ‘I am the constructor’;
}
}