#43648 [Opn->Bgs]: Glob definition should read "mixed", not array

From: Date: Fri, 21 Dec 2007 10:03:48 +0000
Subject: #43648 [Opn->Bgs]: Glob definition should read "mixed", not array
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-363@lists.php.net to get a copy of this message
ID: 43648 Updated by: felipe@php.net Reported By: online at metrofindings dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: all PHP Version: Irrelevant New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Bug #43530 Thanks. Previous Comments: ------------------------------------------------------------------------ [2007-12-21 03:20:28] online at metrofindings dot com Description: ------------ The definition of glob in the PHP documentation reports that glob() returns an array. But the section on return values clearly states that sometimes FALSE is returned. The function definition should report a mixed return value. Also, the return values section says that glob() returns false if the files cannot be read. This is not true. glob() only returns false if the files cannot be read *and* safe_mode is on. http://us2.php.net/glob Reproduce code: --------------- su mkdir foobar; touch foobar/stuff chmod a-rx foobar/stuff chmod a-rx foobar/ exit php -c /etc/php.ini glob.php (with safe_mode off) string(12) "foobar/stuff" array(0) { } php -c /etc/php.ini glob.php (with safe_mode on) string(12) "foobar/stuff" bool(false) Warning: Invalid argument supplied for foreach() in glob.php on line 8 glob.php ============================================ <?php $filesToRemove = glob( dirname(__FILE__).'/foobar/stuff' ); var_dump( dirname(__FILE__).'/foobar/stuff' ); var_dump($filesToRemove); foreach ($filesToRemove as $k => $v) { } ?> Expected result: ---------------- Documentation of return type "mixed". Better note that correctly identifies "safe_mode" as the reason for returning false. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43648&edit=1

« previous php.doc.bugs (#363) next »