syaifulhusein
syaifulhusein

Reputation: 279

mPDF error Message: Methods with the same name as their class will not be constructors in a future version of PHP; m_pdf has a deprecated constructor

I want to print php to pdf using mPDF library in Codeigniter 3.x. But i got error message. The message is "Message: Methods with the same name as their class will not be constructors in a future version of PHP; m_pdf has a deprecated constructor". How to fix it? This is my mPDF file

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class m_pdf {

function m_pdf()
{
    $CI = & get_instance();
    log_message('Debug', 'mPDF class is loaded.');
}

function load($param=NULL)
{
    include_once APPPATH.'/third_party/mpdf60/mpdf.php';

    if ($params == NULL)
    {
        $param = '"en-GB-x","A4","","",10,10,10,10,6,3';
    }

    return new mPDF($param);
}

}

Upvotes: 0

Views: 19168

Answers (2)

Silent Psycho
Silent Psycho

Reputation: 31

Replace this

class m_pdf
{
 function m_pdf()
 {
   
 }
}

With

class m_pdf
{

 function __construct()
 {
   
 }
}

Or You can use higher version to solve this problem.

Upvotes: 1

Vijay Sharma
Vijay Sharma

Reputation: 831

replace with this code

<?php
  if (!defined('BASEPATH')) exit('No direct script access allowed');

include_once APPPATH.'/third_party/mpdf60/mpdf.php';

class M_pdf {

    public $param;
    public $pdf;
    public function __construct($param = "'c', 'A4-L'")
    {
        $this->param =$param;
        $this->pdf = new mPDF($this->param);
    }
}
?>

error occured because you use mpdf function inside mpdf class need to replace with __construct

same class name function you can't use that is deprecated

You can use new mpdf library enter link description here

Upvotes: 3

Related Questions