How to get URL of current page in PHP

For more details on what info is available in the $_SERVER array, see the PHP manual page for it. If you also need the query string (the bit after the ? in a URL), that part is in this variable:

Get JSON object from URL

For this to work, file_get_contents requires that allow_url_fopen is enabled. This can be done at runtime by including: You can also use curl to get the url. To use curl, you can use the example found here: