Re: Re: undefined $_GET index.

From: Date: Wed, 25 Dec 2013 22:30:09 +0000
Subject: Re: Re: undefined $_GET index.
Groups: php.general 
Request: Send a blank email to php-general+get-322623@lists.php.net to get a copy of this message
Thanks you for your explanation!! it help clarify me the technical process. Aziz wrote:
Please refer to the reference Christopher posted on server routers. The router is executed before your script is executed. The same way if you were executing: php test.php. Basically your code was executing twice, once as a router without the r param and once via the browser with the r param. The router was the one throwing the error.
On Wed, Dec 25, 2013 at 4:00 AM, atar <atar.yosef@gmail.com> wrote:
Aziz Saleh wrote: On Tue, Dec 24, 2013 at 9:51 PM, atar <atar.yosef@gmail.com> wrote:
At Christoph Michael Becker:
Thanks you for your advice! it solved the problem. But I didn't succeed to understand HOW the action of dropping the script argument from the command line was worked? why does PHP complain about the undefined $_GET['r'] variable when the test.php script is used as router? Regards, atar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In PHP, when you try to access a variable and that variable doesn't
exist, it throws a notice. In your case the router.php was executed with no r GET param, causing the notice. You can duplicate that by accessing: http://127.0.0.1:8000/test.php(notice the r GET param is not set). As a good practice you should always use isset() before trying to access a param that might not be set: if (isset($_GET['r'])) { // use it }
But why when I use the 'test.php' script as a router, the $_GET['r'] index isn't get defined? that's what wonder me.


« previous php.general (#322623) next »