【问题标题】:How to identify that the string is a path to any file, using PHPcode?如何使用 PHP 代码识别字符串是任何文件的路径? 【发布时间】:2010-05-14 11:01:25 【问题描述】: 使用PHP,如何识别字符串是任何文件的路径? 【问题讨论】: 标签: php filepath 【解决方案1】: http://pt.php.net/is_file $path = 'string'; if(is_file($path)){ // look, it's a file! } 【讨论】: 【解决方案2】: is_file($filename) is_dir($filename) 如果字符串指向现有文件或目录,将返回true。 【讨论】: