note 125350 added to functions.user-defined

From: Date: Thu, 10 Sep 2020 22:58:42 +0000
Subject: note 125350 added to functions.user-defined
Groups: php.notes 
Request: Send a blank email to php-notes+get-215095@lists.php.net to get a copy of this message
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.............. ?> ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.167.36 (proxied: 47.229.27.108) ---- Manual Page -- http://php.net/manual/en/functions.user-defined.php Edit -- https://master.php.net/note/edit/125350 Del: integrated -- https://master.php.net/note/delete/125350/integrated Del: useless -- https://master.php.net/note/delete/125350/useless Del: bad code -- https://master.php.net/note/delete/125350/bad+code Del: spam -- https://master.php.net/note/delete/125350/spam Del: non-english -- https://master.php.net/note/delete/125350/non-english Del: in docs -- https://master.php.net/note/delete/125350/in+docs Del: other reasons-- https://master.php.net/note/delete/125350 Reject -- https://master.php.net/note/reject/125350 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215095) next »