2014-09-03 86 views
0

我是個簡單的PDF創世爲PHP,基本上它:執行一個PHP頁面並存儲一個變量?使用

<?php 
$html = "test"; 
inclued("MPDF57/mpdf.php"); 
$mpdf=new mPDF(); 
$mpdf->WriteHTML($html); 
$mpdf->Output(); 
exit; 
?> 

如果我運行此,一個PDF打開了一個帶有文本「測試」。

現在我的問題是,我想出一個整個網站,所以即時通訊在單獨的文件上做這樣的事情,它的名字爲printx.php。在邊DE文件是這樣的

<?php 
$ID=$_GET['ID']; 
$result=mysqli_query($link,"SELECT * FROM table WHERE ID = '$id'); 
?> 
<html> 
<table><tr><td> 
<?php var_dump($result);?> 
</td></tr></table> 
</html> 

代碼是有很多,但它不事在這裏,因爲如果我通過10.0.0.99/printx.php?ID=13呼叫的站點它的自我,它工作正常

,如果我做了以下

<?php 
$html = require("printx.php?ID=13"); 
inclued("MPDF57/mpdf.php"); 
$mpdf=new mPDF(); 
$mpdf->WriteHTML($html); 
$mpdf->Output(); 
exit; 
?> 

的空網站被作爲PDF

爲什麼產生的?網站沒有進入pdf的原因是什麼?

回答

2

使用$html = file_get_contents("printx.php?ID=13");

,而不是$html = require("printx.php?ID=13");

嗯... file_get內容可能需要完整的URL,這樣 file_get_contents("http://10.0.0.99/printx.php?ID=13");

+0

完美的作品! :) – 2014-09-03 15:45:09

相關問題