Reputation: 2863
Look at the following PHP:
<?php
var_dump($_POST);
?>
I am running this program using the following URL:
http://192.168.2.1:8888/a-s/bootstrap/php/test.php?lookup_word=parrot
And the result I am getting is this:
array(0) { }
What sorcery is this? Why is it returning an empty array while I am feeding it at least one key-value pair?
Upvotes: 1
Views: 1553
Reputation: 627
It's returning an empty array simply because the $_POST
array in empty. You have not POSTED any data for $_POST
to fetch.
Passing arguments via the URL sets them to $_GET
not $_POST
to set data to $_POST
you have to POST data via an HTML form, curl etc
try
var_dump($_GET);
Also please learn more about $_POST
& $_GET
Upvotes: -1
Reputation: 2604
If you are looking for looking_word
parameter in $_POST
variable, you won't get it as its part of a GET request and will be available in $_GET
. If you want to make it general you can check $_REQUEST
variable.
<?php
var_dump($_REQUEST);
?>
As others mentioned, please have a look into the GET and POST concepts and $_GET
, $_POST
and $_REQUEST
variables.
Upvotes: -1
Reputation: 342
It's because your not getting the variable you defined in your URL.
you should do it like this:
var_dump($_GET['lookup_word']);
Upvotes: 3