2014-02-24 31 views
-1

如果文件.xls不存在,我需要編輯此腳本以顯示頁面的另一部分。例如$發現= false時,顯示flashexit.php如何編輯這個php腳本?如果文件存在顯示這個,如果不顯示另一個?

<? 
    $page = $_SERVER['PHP_SELF']; 
    $sec = "30"; 
    $find = '/flash/file/FLASH.xls'; //The file to find 
    $paths = explode(PATH_SEPARATOR, get_include_path()); 
    $found = false; 
    foreach($paths as $p) { 
     $fullname = $p.DIRECTORY_SEPARATOR.$find; 
     if(is_file($fullname)) { 
     $found = $fullname; 
     include($_SERVER["DOCUMENT_ROOT"]."/inc/flashnewblu.inc.php"); 
     break; 
     } 
    } 
    ?> 
+0

請更好地解釋自己。 – OfirH

回答

2

我認爲你需要的是檢查這個link。是與功能file_exists

1

您可以檢查文件是否具有內置功能file_exists存在:

<?php 
$find = '/flash/file/FLASH.xls'; //The file to find 
$paths = explode(PATH_SEPARATOR, get_include_path()); 
$found = false; 
foreach($paths as $p) { 
    $fullname = $p.DIRECTORY_SEPARATOR.$find; 
    if(file_exists($fullname)) { 
    $found = $fullname; 
    include($_SERVER["DOCUMENT_ROOT"]."/inc/flashnewblu.inc.php"); 
    break; 
    } 
} 
if(!$found) { 
    echo 'File '.$fullname.' doesn\'t exists. Make a redirection to flashexit.php'; 
} 
?> 
相關問題