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.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php