我在使用 PHP 5.3.0 中包含的 glob://流包装器时遇到问题版本。我正在使用以下 PHP 版本:
PHP 5.3.1-0.dotdeb.1 with Suhosin-Patch (cli) (built: Dec 5 2009 20:08:29) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
当我尝试执行以下命令时example来自 PHP.net 网站:
<?php
// Loop over all *.php files in ext/spl/examples/ directory
// and print the filename and its size
$it = new DirectoryIterator("glob://*.php");
foreach($it as $f) {
printf("%s: %.1FK\n", $f->getFilename(), $f->getSize()/1024);
}
?>
Note that I remove the folder from the original example and left only the php extension
我收到 PHP 错误,并显示以下消息:
SplFileInfo::getSize(): stat failed for [first php file name].php
在 Google 搜索此错误时,我发现有人有 same problem一年前,但看起来他们已经修复了它。
所以...我的问题是:有人在使用 glob://包装器吗?难道我做错了什么?大家有同样的问题吗?
注意:我已经知道我可以用其他不同的方式做同样的事情,但我想测试 glob://流包装器:)
最佳答案
错误信息非常清楚。它在根目录中寻找“/00.php”(注意斜杠)。我想你在这里需要 getPathName ( http://www.php.net/manual/en/directoryiterator.getpathname.php ) 而不是 getFileName
关于PHP 5.3.1 全局 ://exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2280322/