2013-03-13 133 views
0

在我的網站上,我使用一個名爲mpdf http://www.mpdf1.com/mpdf/index.php的php類來創建用於下載的pdf。在另一個php腳本中使用exec()函數執行php腳本

它通過使用file_get_contents('list.php')函數來獲取內容爲html,準備轉換爲pdf。

它的作品真的很好,可惜我的網站它只返回實際的PHP代碼,而不是生成的HTML:

<?php include 'inc/head.php'?> 
<?php include 'inc/header.php'?> 
<?php include 'inc/gold_packageinc.php'?> 
<?php include 'inc/footer.php'?> 

如果我能想出如何使用前

exec('list.php') 

file_get_contents('list.php') 

我確定它會工作。事情似乎很難做到。顯然你需要引用php文件或其他東西,但我不能這樣做。我現在創建了一個由PHP驅動的網站,但我不知道什麼是'shell'或什麼!

如果有人能解釋如何讓exec('list.php')工作,我會非常感激!完全開放以解決問題。也許'輸出緩衝'如果有人能解釋?

回答

1

做這樣的:

$content = include ('list.php'); 

代替,而不是使用file_get_contents返回字符串,請使用$content;這樣的$content將包含輸出字符串list.php

0
exec('list.php') is wrong,If you need to execute a php file with exec() function,You need to pass the name of file as argument to PHP.exe file 

eg: 
     exec('C:/xampp/bin/PHP.exe "C:/xampp/htdocs/list.php"'); 

你需要考慮到文件的完整路徑