Pregunta

I am trying to capture a value form requested URL in php. My code is given below:

http_get("http://domain.com/view.php?token=", $value); 
 echo $value;

But once I go to this url http://domain.com/view.php?token=myvalue" I am getting the following error.

Fatal error: Call to undefined function http_get() in F:\Server\xampp\htdocs\p\data-repository\view.php on line 11

My primary objective is to show the $value.

¿Fue útil?

Solución

To get value from the URL,you can use either of GET or REQUEST method in PHP.

Using GET

$value=$_GET['token'];
echo $value;

Using REQUEST

$value=$_REQUEST['token'];
echo $value;

Otros consejos

I think you want something like:

$value = $_GET['token'];
echo $value;

OR - try assigning http_get to a variable (as shown in the manual):

$response = http_get("http://www.example.com/", array("timeout"=>1), $info);
print_r($info);

Have you checked the apache log? Are you sure pecl_http is installed and enabled?

Also be aware http_get returns a string (the result of the website). The second argument is supposed to be the options. The third argument will be filled with the server response.

You could also try to use cURL (curl_init(), curl_setopt(), curl_exec(), curl_close()).

http_get is function to receive of http request.
If you want GET value, use this:

$_GET['token']
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top