$file_ext = strtolower(substr(strrchr($filename, '.'), 1));$allow_type = array('html', 'txt', ..........);if(in_array($file_ext, $allow_type)) echo 'yes';========================================
偶的论坛:
www.chinesehis.com/starry/index.php

解决方案 »

  1.   

    $patten='/\w+(?=\.asp|\.php|\.html)/i';
    if(preg_match($patten,$file)){
    }
      

  2.   

    $patten='/\w+(?=\.asp|\.php|\.html)/i';
    if(preg_match($patten,$file)){
    }
    这段我看不大明白,解说一下好吗?
      

  3.   

    $patten='/\w+(?=\.asp|\.php|\.html)/i';就是匹配***.asp ***.php 等等了,把自己需要的都加在后面。(?=pattern)
    正向预查,在任何匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如, 'Windows (?=95|98|NT|2000)' 能匹配 "Windows 2000" 中的 "Windows" ,但不能匹配 "Windows 3.1" 中的 "Windows"。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之后开始。上面这一段是我复制的了。以前,csdn上面有人发表过专门介绍正则表达式的文章了。
    这就是其中的内容的。preg_match ,是perl风格的匹配了。如果以前用过perl,可能更习惯这个函数的了。
      

  4.   

    eregi("\.(asp|php|htm|txt|pl|css|js|inc)",$file)