2014-09-03 45 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

相关问题