note 112184 added to language.variables.superglobals

From: Date: Tue, 14 May 2013 18:09:26 +0000
Subject: note 112184 added to language.variables.superglobals
Groups: php.notes 
Request: Send a blank email to php-notes+get-194806@lists.php.net to get a copy of this message
Since PHP 5.4, you cannot use a superglobal as the parameter to a function. This causes a fatal error: function foo($_GET) { // whatever } It's called "shadowing" a superglobal, and I don't know why people ever did it, but I've seen it out there. The easy fix is just to rename the variable $get in the function, assuming that name is unique. There was no deprecation warning issued in previous versions of PHP, according to my testing, neither in 5.3 nor 5.2. The error messages in 5.4 are: Fatal error: Cannot re-assign auto-global variable _GET in... Fatal error: Cannot re-assign auto-global variable _COOKIE in... etc. ---- Server IP: 69.147.83.199 Probable Submitter: 66.207.76.85 ---- Manual Page -- http://php.net/manual/en/language.variables.superglobals.php Edit -- https://master.php.net/note/edit/112184 Del: integrated -- https://master.php.net/note/delete/112184/integrated Del: useless -- https://master.php.net/note/delete/112184/useless Del: bad code -- https://master.php.net/note/delete/112184/bad+code Del: spam -- https://master.php.net/note/delete/112184/spam Del: non-english -- https://master.php.net/note/delete/112184/non-english Del: in docs -- https://master.php.net/note/delete/112184/in+docs Del: other reasons-- https://master.php.net/note/delete/112184 Reject -- https://master.php.net/note/reject/112184 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194806) next »