. Advertisement .
..3..
. Advertisement .
..4..
I am tired of fixing the problem: methods with the same name as their class will not be constructors in a future version of php in the php; even if I get the reference from another forum, it still returns an error:
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; emailcomm has a deprecated constructor in /var/www/html/portal/application/libraries/emailcomm.php on line 3
To identify the problem, I will show you the detail here:
class emailcomm
{
var $to;
var $subject;
var $message;
var $from='From:';
function emailcomm()
{
$this->CI=&get_instance();
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '465';
$config['_smtp_auth']=TRUE;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'Web8*98*2015';
$config['smtp_timeout'] = '60';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
$this->CI->load->library('email',$config);
$this->CI->email->initialize($config);
}
}
How do I do that? Could you support me in improving this problem?
The cause: The cause of this error is that if PHP cannot find a
__construct()
function for a given class in prior versions, it will look for the old-style constructor function by the class name, however old-style constructors are now DEPRECATED inPHP 7.0
and will be deleted in a future version.The solution: To solve this problem, you can rename your
emailcomm()
function with__construct()
as the following:Solution: Change the name of your function emailcomm() in
__construct()
Explanation In the previous versions of
PHP
PHP
searched for the__construct()
function for the given class. However, thePHP 7.0
will now search for the old-style constructor function by the class name. Old style constructors will no longer be DEPRECATED and will be removed from a future release.__construct()
should be used in all new code. PHP manual