|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-26 14:45 UTC] bwoebi@php.net
-Status: Open
+Status: Not a bug
[2016-03-26 14:45 UTC] bwoebi@php.net
[2016-03-26 16:19 UTC] pat at breakfree dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
Description: ------------ A false switch case is returning valid. Perhaps related to key index returned from stat()? PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies Test script: --------------- <?php $s = stat('/tmp'); /* * I was interested in data from a few keys. However I found the 0/dev key is always resulting as a true case. */ $x = 0; foreach($s as $k => $v) { switch($k) { case 'this_does_not_exist_and_should_never_occur': echo 'Yet this case occurs: ' . $k . ', ' . $v . "\n"; $x++; break; default: break; } } echo "x=" . $x . "\n"; ?> Expected result: ---------------- x=0 Actual result: -------------- Yet this case occurs: 0, 64769 x=1