#50414 [NEW]: strange return attitude in user functions
| From: | bakhtiyor dot bahriddinov at gmail dot com | Date: | Tue, 08 Dec 2009 19:08:52 +0000 |
| Subject: | #50414 [NEW]: strange return attitude in user functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-145535@lists.php.net to get a copy of this message | ||
From: bakhtiyor dot bahriddinov at gmail dot com
Operating system: Windows XP SP2
PHP version: 5.2.11
PHP Bug Type: Scripting Engine problem
Bug description: strange return attitude in user functions
Description:
------------
Why return functions in recursive functions doesn't exit and return
value from function but instead loops until end of loop?
Reproduce code:
---------------
<?php
function check_folder($directory){
if ($dir = @opendir($directory)){
while ($file = readdir($dir)) {
if (($file != ".")&&($file != "..")) {
$tempDir = $directory."/".$file;
if (is_dir($tempDir)) {
check_folder($tempDir);
} else {
$file_name = $directory."/".$file;
$file_in_use=check_in_resources($file_name);
if ($file_in_use!=false){ /
return 1;
}
}
}
}
}
return 0;
}
Expected result:
----------------
i expected function to return 1 when var $file_in_use!=false. but it
everytime returns 0
Actual result:
--------------
i expected function to return 1 when var $file_in_use!=false. but it
everytime returns 0
--
Edit bug report at http://bugs.php.net/?id=50414&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50414&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50414&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50414&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50414&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50414&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50414&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50414&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50414&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50414&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50414&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50414&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50414&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50414&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50414&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50414&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50414&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50414&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50414&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50414&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50414&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50414&r=mysqlcfg