2012-10-14 23 views
0

我想支票夹,如果它包含PDF就会去其他的过程中,如果不包含PDF,它会跳过过程。 下面的代码:检查文件,如果不包含PDF它会跳过下一道工序

<?php 
set_time_limit(0); 
$savePath = 'D:/AppServ/www/aca/'; 

$dir  = opendir($savePath); 
$check = glob($savePath.'*.pdf'); 
if($check === ''){ exit();} // if not found pdf don't do process below this 

// many other process below 
?> 

但过程中仍然运行,如何突破呢?谢谢:)

+0

请记住,使用“文件扩展名”,以确定文件的类型是非常80ish ... – arkascha

回答

0

glob返回时,有没有匹配的空数组,但你正在测试它是否等于一个空字符串。检查数组是否为空。

0
<?php 
    set_time_limit(0); 
    $savePath = 'D:/AppServ/www/aca/'; 

    $dir  = opendir($savePath); 
    $check = glob($savePath.'*.pdf'); 
    if(empty($check)){ exit();} // if not found pdf don't do process below this 

    // many other process below 
?> 
0
if(!count($check)) 
    exit; 

你有一个字符串,它总是会返回false比较$check

相关问题