note 125350 deleted from functions.user-defined by cmb

From: Date: Fri, 11 Sep 2020 14:04:05 +0000
Subject: note 125350 deleted from functions.user-defined by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215099@lists.php.net to get a copy of this message
Note Submitter: greenbluemoonlight at gmail dot com ---- Notice that recursion($a+1) has the same output as ++a. If recursion($a++) is mistakenly used instead of recursion(++$a), The output is infinite loop. <?php ////recursion($a + 1) function recursion($a) { if ($a < 4) { echo $a . "\n"; recursion($a + 1); } } recursion(1); //Outputs: 1 2 3 ////recursion(++$a) function recursion($a) { if ($a < 4) { echo $a . "\n"; recursion(++$a); } } recursion(1); //Outputs: 1 2 3 ////recursion($a++) function recursion($a) { if ($a < 4) { echo $a . "\n"; recursion($a++); } } recursion(1); //Outputs: INFINITE LOOP !!! 1 1 1 1 1.............. ?>

« previous php.notes (#215099) next »