note 112395 added to reserved.variables.globals

From: Date: Tue, 11 Jun 2013 17:58:31 +0000
Subject: note 112395 added to reserved.variables.globals
Groups: php.notes 
Request: Send a blank email to php-notes+get-195131@lists.php.net to get a copy of this message
Watch out when you are trying to set $GLOBALS to the local variable. Even without reference operator "&" your variable seems to be referenced to the $GLOBALS You can test this behaviour using below code <?php /** * Result: * POST: B, Variable: C * GLOBALS: C, Variable: C */ // Testing $_POST $_POST['A'] = 'B'; $nonReferencedPostVar = $_POST; $nonReferencedPostVar['A'] = 'C'; echo 'POST: '.$_POST['A'].', Variable: '.$nonReferencedPostVar['A']."\n\n"; // Testing Globals $GLOBALS['A'] = 'B'; $nonReferencedGlobalsVar = $GLOBALS; $nonReferencedGlobalsVar['A'] = 'C'; echo 'GLOBALS: '.$GLOBALS['A'].', Variable: '.$nonReferencedGlobalsVar['A']."\n\n"; ---- Server IP: 69.147.83.199 Probable Submitter: 83.6.97.225 ---- Manual Page -- http://php.net/manual/en/reserved.variables.globals.php Edit -- https://master.php.net/note/edit/112395 Del: integrated -- https://master.php.net/note/delete/112395/integrated Del: useless -- https://master.php.net/note/delete/112395/useless Del: bad code -- https://master.php.net/note/delete/112395/bad+code Del: spam -- https://master.php.net/note/delete/112395/spam Del: non-english -- https://master.php.net/note/delete/112395/non-english Del: in docs -- https://master.php.net/note/delete/112395/in+docs Del: other reasons-- https://master.php.net/note/delete/112395 Reject -- https://master.php.net/note/reject/112395 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195131) next »