How to fix Methods with the same name as their class will not be constructors in a future version of PHP

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.

How to fix Methods with the same name as their class will not be constructors in a future version of PHP
how to fix methods with same name as their class will not be constructors 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’;
}
}