note 113131 added to language.operators.precedence

From: Date: Tue, 03 Sep 2013 14:02:46 +0000
Subject: note 113131 added to language.operators.precedence
Groups: php.notes 
Request: Send a blank email to php-notes+get-196151@lists.php.net to get a copy of this message
In the documentation, it states that "mixing ++ and + produces undefined behavior". I wrote the following script to test this, and it appears that the behavior isn't erratic. Not sure if this is because of the version or not. Tested on PHP 5.5.3: <?php $i = 1; $fourCount = 0; $fiveCount = 0; while($i <= 1000000000) { $a = 1; $derp = ++$a + $a++; if($derp == 4) { $fourCount++; } elseif($derp == 5) { $fiveCount++; } else { echo $a . "\n"; exit("lulz, breakage\n"); } $i++; } echo "Four Count: " . $fourCount . "\n"; echo "Five Count: " . $fiveCount . "\n"; ?> The output is: Four Count: 1000000000 Five Count: 0 ---- Server IP: 69.147.83.199 Probable Submitter: 69.167.130.9 ---- Manual Page -- http://php.net/manual/en/language.operators.precedence.php Edit -- https://master.php.net/note/edit/113131 Del: integrated -- https://master.php.net/note/delete/113131/integrated Del: useless -- https://master.php.net/note/delete/113131/useless Del: bad code -- https://master.php.net/note/delete/113131/bad+code Del: spam -- https://master.php.net/note/delete/113131/spam Del: non-english -- https://master.php.net/note/delete/113131/non-english Del: in docs -- https://master.php.net/note/delete/113131/in+docs Del: other reasons-- https://master.php.net/note/delete/113131 Reject -- https://master.php.net/note/reject/113131 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196151) next »