Reply to Re: [PHP] updated php $_GET

Your name:

Reply:


Posted by Marek Kilimajer on 02/12/05 15:03

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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация