1

I am getting proper url by $_SERVER[REQUEST_URI] by GET method, but it doesn't work with POST.

Is there any alternative to $_SERVER[REQUEST_URI] so that I get url of post line like so: url=www.example.com?id=12&name=xyz&address=pqr

JSON C11
  • 11,272
  • 7
  • 78
  • 65
King
  • 11
  • 3

2 Answers2

1

use laravel Request facade Request::fullUrl(); to get the url of request

Junaid
  • 1,004
  • 8
  • 24
  • I am only getting url http://localhost:8000/machine but I want complete query string like http://localhost:8000/machine?name=abc&age=20&city=mumbai – King Feb 03 '16 at 11:49
  • no it is not working. I am sending post parameter by poster and postman – King Feb 03 '16 at 12:03
  • solution: . $p= (array)json_decode(file_get_contents("php://input")); echo http_build_query($p); . output:device_id=r1&x=5&y=10 – King Feb 03 '16 at 12:21
0

$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

This should do the job for you.

Sauced Apples
  • 1,163
  • 2
  • 14
  • 37