Deprecated Constructor in PHP Class

Still converting old PHP code and upgrading to PHP 7.0, I receive a message like this:


Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Validate_fields has a deprecated constructor in

Looking at the code I see this:


class Validate_fields {
var $fields = array();
var $messages = array();
var $check_4html = false;
var $language;
var $time_stamp;
var $month;
var $day;
var $year;

function Validate_fields() {
$this->language = "us";
$this->create_msg();
}

The message means that the class name Validate_fields and the constructor function Validate_fields() have the same name. The solution is to use a __constructor() instead of function Validate_fields().
Something like this:

class Validate_fields {
var $fields = array();
var $messages = array();
var $check_4html = false;
var $language;
var $time_stamp;
var $month;
var $day;
var $year;

function __constructor() {
$this->language = "us";
$this->create_msg();
}

The error is no more.