note 56749 deleted from language.variables.scope by cmb

From: Date: Wed, 18 Mar 2020 12:25:47 +0000
Subject: note 56749 deleted from language.variables.scope by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214340@lists.php.net to get a copy of this message
Note Submitter: tc underline at gmx TLD ch ---- Pay attention while unsetting variables inside functions: <?php $a = "1234"; echo "<pre>"; echo "outer: $a\n"; function testa() { global $a; echo " inner testa: $a\n"; unset ($a); echo " inner testa: $a\n"; } function testb() { global $a; echo " inner testb: $a\n"; $a = null; echo " inner testb: $a\n"; } testa(); echo "outer: $a\n"; testb(); echo "outer: $a\n"; echo "</pre>"; ?> /***** Result: outer: 1234 inner testa: 1234 inner testa: outer: 1234 inner testb: 1234 inner testb: outer: ******/ Took me 1 hour to find out why my variable was still there after unsetting it ... Thomas Candrian

« previous php.notes (#214340) next »