note 62441 added to reserved.variables

From: Date: Tue, 28 Feb 2006 20:00:17 +0000
Subject: note 62441 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-104574@lists.php.net to get a copy of this message
Note that it's a very, very bad idea to append to global variables in a loop, unless you really, really mean to do so in a global context. I just a while ago hung my server with a snippet of code like this: <?php $host = $_SERVER['HTTP_HOST']; $uri = rtrim($_SERVER['PHP_SELF'], "/\\"); $GLOBALS['SITE_ROOT'] = "http://$host$uri"; while ($i < somenumber) readfile($GLOBALS['SITE_ROOT'] = $GLOBALS['SITE_ROOT'] . '/this/file.php'); $i++ } ?> While it is an entertaining and unusual method of creating very long URLs and breaking servers, it's a pretty awesomely bad idea (Especially considering that the script in question ran concurrently with others of it's type, so the value in $GLOBALS['SITE_ROOT'] was unknown.) ---- Server IP: 216.194.113.175 Probable Submitter: 12.33.21.99 ---- X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, UPPERCASE_25_50 autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/note/edit/62441 Del: integrated -- http://master.php.net/note/delete/62441/integrated Del: useless -- http://master.php.net/note/delete/62441/useless Del: bad code -- http://master.php.net/note/delete/62441/bad+code Del: spam -- http://master.php.net/note/delete/62441/spam Del: non-english -- http://master.php.net/note/delete/62441/non-english Del: in docs -- http://master.php.net/note/delete/62441/in+docs Del: other reasons-- http://master.php.net/note/delete/62441 Reject -- http://master.php.net/note/reject/62441 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104574) next »