如果第6行(.include ...)被取消註釋,那麼以下腳本將失敗 - 無論文件「somefile.php」的內容是什麼。即使是一個0字節(空)的文件。我試圖移動這些函數並創建一個「utils.php」庫,這是PHP世界中的一個不容忽視的問題嗎? Error_log是空的。我在Linux 2.6.32上使用PHP 5.2.17。謝謝。爲什麼包含空文件會導致PHP腳本失敗?
<?php // File: index.php
error_reporting (E_ALL);
ini_set ('display_errors', 1);
//Uncomment the following line and the script fails
//.include "somefile.php";
function imageToBrowser ($pseudonym, $filePath) {
header("Pragma: public");
header("Expires: 0");
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Length: ".(string)(filesize($filePath)));
header('Content-Type: application/x-download');
header('Content-Disposition: attachment; filename="'.$pseudonym.'.png"');
header('Content-Transfer-Encoding: binary');
if ($file = fopen($filePath, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
print(fread($file, filesize($filePath)));
flush();
}
fclose($file);
}}
if (isset($_GET['showImage']) && ($imageMask = $_GET['showImage'])) {
imageToBrowser ($imageMask, 'Clear64.png'); // Use any .png file in $cwd
} else {
echo "<html><body><center>\n";
echo "<img border='0' src=\"{$_SERVER['PHP_SELF']}?showImage=365\" alt=\"Missing Image\"/>\n";
echo "</center></body></html>";
}
?>
什麼正在發生的確切的錯誤?說它不起作用並不能告訴我們爲什麼。 –
希望在取消註釋時,還可以在'include'之前刪除點。 – zneak
頁面爲空(空白)。沒有錯誤信息,當然也不是我用這行註釋得到的圖像。 –