In PHP, how to get the full current URL with all $_GET parameters?
In PHP, to get the full URL of the current page with parameters, the best option is to concatenate the following variables :
// Get the full URL with protocole and parameters
// As an example: https://www.example.com/page.html?param1=abc¶m2=123
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
In PHP, to get the full URL of the current page with parameters, the best option is to concatenate the following variables :
// Get the full URL with protocole and parameters
// As an example: https://www.example.com/page.html?param1=abc¶m2=123
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
In PHP, to get the full URL of the current page with parameters, the best option is to concatenate the following variables :
// Get the full URL with protocole and parameters
// As an example: https://www.example.com/page.html?param1=abc¶m2=123
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
In PHP, to get the full URL of the current page with parameters, the best option is to concatenate
// Get the full URL with protocole and parameters
// As an example: https://www.example.com/page.html?param1=abc¶m2=123
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
In PHP, to get the full URL of the current page with parameters, the best option is to concatenate
// Get the full URL with protocole and parameters
// As an example: https://www.example.com/page.html?param1=abc¶m2=123
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
To get the full URL with parameters in PHP, the best option is to concatenate
// Get the full URL with protocole and parameters
$url = ( ($_SERVER['HTTPS'] ?? 'off' === 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 12616 | en | https://en.ans.wiki/624/in-php-how-to-get-the-full-current-url-with-all-_get-parameters | 5 |