Re: Re: undefined $_GET index.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> wrote:

Aziz Saleh wrote:

 On Tue, Dec 24, 2013 at 9:51 PM, atar <atar.yosef@xxxxxxxxx> 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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux