Re: Re: undefined $_GET index.
| From: | tamouse pontiki | Date: | Wed, 25 Dec 2013 02:18:53 +0000 |
| Subject: | Re: Re: undefined $_GET index. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322620@lists.php.net to get a copy of this message | ||
On Tue, Dec 24, 2013 at 6:55 PM, Aziz Saleh <azizsaleh@gmail.com> 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
> }
>
Oops, Aziz scooped me on this one!