我是PHP和代碼點火器的新手,在嘗試將動態數據內容轉換爲靜態HTML文件時遇到了一些問題。這是代碼片段。當我請求代碼片段文件時,它只打印錯誤111111111沒有別的。無法理解這裏的錯誤。PHP ob_start無法正常工作
這是我的原始代碼,這裏試圖生成帶有動態內容的靜態html文件。它不適用於我
<?php
echo "Error 111111111";
ob_start();
$fileName = "sample.html";
?>
<html>
<body>
Some html is here
</body>
</html>
<?php
try{
$output = ob_get_contents(); // get contents of trapped output
//write to file, e.g.
$newfile = $fileName;
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file);
ob_end_clean(); // discard trapped output and stop trapping
}catch (Exception $ex){
echo "Error ".$ex->getMessage();
}
?>
你還指望它來打印? – 2011-01-21 10:41:28