2015-11-02 77 views
1

我正在codeigniter 3中使用一個項目,而且我正在使用mpdf v5.6。 mpdf示例工作完美,但是當我將mpdf與codeigniter 3集成時,會引發一些錯誤。 我的控制器代碼codeigniter 3中的Mpdf問題

public function pdf() 
    { 
     $this->load->library('mpdf'); 
     $this->mpdf->WriteHTML('<p>Hello There</p>'); 
     $this->mpdf->Output(); 
    } 

錯誤像

A PHP Error was encountered 

Severity: 8192 

Message: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead 

Filename: includes/functions.php 

Line Number: 74 
Backtrace: 

File: /Users/bappa/Desktop/codeigniter/mpdf/includes/functions.php 
Line: 74 
Function: preg_replace 

File: /Users/bappa/Desktop/codeigniter/application/libraries/Mpdf.php 
Line: 31062 
Function: strcode2utf 

File: /Users/bappa/Desktop/codeigniter/application/libraries/Mpdf.php 
Line: 12302 
Function: purify_utf8 

File: /Users/bappa/Desktop/codeigniter/application/controllers/Welcome.php 
Line: 29 
Function: WriteHTML 

File: /Users/bappa/Desktop/codeigniter/index.php 
Line: 292 
Function: require_once 

,並在錯誤頁面

mPDF error: Some data has already been output to browser, can't send PDF file 

問題出在哪裏結束?謝謝。

+0

這個問題,你可以展示你的代碼,以及 –

回答

3

打開導致錯誤的那一行。我認爲錯誤行都是這樣的,

$str = preg_replace('/&#([0-9]+)\;/me', "code2utf('\1',{$lo})",$str); 
$str = preg_replace('/&#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\1',{$lo})",$str); 

更換這些線路,

$str = preg_replace_callback('/&#([0-9]+)\;/m', function($m){ return code2utf($m[1],$lo); }, $str); 
$str = preg_replace_callback('/&#([0-9]+)\;/m', function($m){ return codeHex2utf($m[1],$lo);}, $str); 

github

+0

謝謝你的問題解決了 –

+0

@try_simple_code很高興它幫助你:) –