note 94259 added to language.variables.scope

From: Date: Mon, 26 Oct 2009 01:17:53 +0000
Subject: note 94259 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-162091@lists.php.net to get a copy of this message
Use the superglobal array $GLOBALS is faster than the global keyword. See: //Using the keyword global $a=1; $b=2; function sum() { global $a, $b; $a += $b; } $t = microtime(true); for($i=0; $i<1000; $i++) { sum(); } echo microtime(true)-$t; echo " -- ".$a."<br>"; //Using the superglobal array $a=1; $b=2; function sum2() { $GLOBALS['a'] += $GLOBALS['b']; } $t = microtime(true); for($i=0; $i<1000; $i++) { sum2(); } echo microtime(true)-$t; echo " -- ".$a."<br>"; ---- Server IP: 69.147.83.197 Probable Submitter: 200.215.64.66 ---- Manual Page -- http://www.php.net/manual/en/language.variables.scope.php Edit -- https://master.php.net/note/edit/94259 Del: integrated -- https://master.php.net/note/delete/94259/integrated Del: useless -- https://master.php.net/note/delete/94259/useless Del: bad code -- https://master.php.net/note/delete/94259/bad+code Del: spam -- https://master.php.net/note/delete/94259/spam Del: non-english -- https://master.php.net/note/delete/94259/non-english Del: in docs -- https://master.php.net/note/delete/94259/in+docs Del: other reasons-- https://master.php.net/note/delete/94259 Reject -- https://master.php.net/note/reject/94259 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162091) next »