Re: updated php $_GET

From: Date: Sat, 12 Feb 2005 13:16:09 +0000
Subject: Re: updated php $_GET
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-208584@lists.php.net to get a copy of this message
"Marek Kilimajer" <lists@kilimajer.net> wrote in message news:420DFEA3.1030702@kilimajer.net... > Jacco Ermers wrote: >> Hello everyone, >> >> I recently installed php5 onto my windows IIS. Previous I had php running >> on Apache. I coded a page (testing purposes) but now I get errors. the >> page can be viewed on a remote server (without the errors) >> http://seabird.jmtech.ca >> >> Locally I receive these errors: >> >> Undefined index: section in >> C:\Inetpub\wwwroot\Seabird-local\includes\submenu.php on line 3 >> >> if($_GET['section']=='') etc. >> It used to be that I could use a section == '' >> is it new to php5 that I cannot? and I also used to be able to use >> $_GET[section] and now I have to use $_GET['section'] >> >> did I overlook anything configuring my php.ini or is this due to my new >> enviroment? >> >> Thank you for helping > > This is due to different setting in error reporting, now you have also > E_NOTICE turned on. > > if($_GET['section']=='') > > should be coded as: > > if(empty($_GET['section'])) > > If GET variable 'section' is not sent, it is not equal to '', it does not > even exists, is undefined. Using it triggers error of level E_NOTICE. > > If you write > > $_GET[section] > > php is looking for constant named 'section'. However, it does not exists, > so an error of level E_NOTICE is triggered. Undefined constant is then > converted to string with its name. So you get $_GET['section'] in the end. > > It's a good practice have full error reporting turned on, since this will > help you spot errors and write safer code. Thank you, that did the trick. Now it works without problems.

« previous php.general (#208584) next »