Re: undefined $_GET index.
| From: | Christoph Michael Becker | Date: | Tue, 24 Dec 2013 23:11:05 +0000 |
| Subject: | Re: undefined $_GET index. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322616@lists.php.net to get a copy of this message | ||
atar wrote:
> I've written the following code:
>
>> <?php
>> var_dump($_GET['r']);
>> ?>
>
> and save it to a file named: test.php.
> Afterwards, I've launch the PHP binary on my Debian Linux machine with
> the following line:
>
>> "php -S 127.0.0.1:8000 test.php"
>
> in order to use the built-in PHP web server.
> then, I've fired up my browser and enter the following in the location bar:
>
>> "http://127.0.0.1:8000/test.php?r=something"
>
> The PHP built-in web server responded in the terminal as followed:
>
>> "[Tue Dec 24 23:56:31 2013] PHP Notice: Undefined index: r in
>> /home/user/Desktop/new_raf_jewl/test.php on line 3"
>
> My question is simply why? what's wrong with my above PHP snippet? and
> the strange thing here is that the PHP binary replies to the browser
> with the following:
>
>> " string(9) "something" "
>
> so what's going here? is the $_GET['r'] index is defined or not?
>
> NOTE: I'm using the php-cli (Command Line Interface) version of the PHP
> binary.
Um, the command line for starting the built-in webserver seems wrong.
According to the documentation[1], test.php is used as router script,
what is probably not intended. Just try to start the server without the
script argument:
php -S 127.0.0.1:8000
[1]
<http://www.php.net/manual/en/features.commandline.webserver.php#example-383>
--
Christoph M. Becker