如果文件.xls不存在,我需要编辑此脚本以显示页面的另一部分。例如$ found = false,show flashexit.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 :(得分:2)
我认为您需要检查此link。与函数file_exists
答案 1 :(得分: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';
}
?>