我有一個簡單的if語句可以在我的本地機器上運行,但是當我上傳它時,tom ypaid站點在我的主頁上出現錯誤。PHP如果/ Elseif聲明不能正常工作
錯誤:
Warning: include(./pages/.php) [function.include]: failed to open stream: No such file or directory in /home/a5410474/public_html/index.php on line 33
Warning: include() [function.include]: Failed opening './pages/.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a5410474/public_html/index.php on line 33
驗證碼:
<?php
if (isset($_GET['p']) && $_GET['p'] != NULL || $_GET['p'] != '') {
$p = mysql_real_escape_string($_GET['p']);
}elseif ($_GET['p'] == '' || $_GET['p'] == NULL){
$p = 'home';
}
include("./pages/".$p.".php");
?>
你需要過濾'$ p'變量以確保它不包含像'../../../../usr/share/PHP/something'。你可能只想要字母。更好的方法是保存'。/ pages'中實際存在的有效文件數組並檢查輸入值。 –