GET a URL parameter with PHP

I would like to capture the lang variable and then translate the page based on this variable.

global $jwp_lang;
$url = $_SERVER["REQUEST_URI"];
echo $url;

for example if the url contains http://localhost/about/?lang=fr I would like to capture this value.

Related posts

2 comments

  1. You can easily capture the value of lang variable using php Super Global variable $_GET :

    $lang = $_GET['lang'];
    echo $lang;
    
  2. It is better to pass the URL parameters using add_query_var, and get the parameter using get_query_var.

    Because, they can handdle the set, and get of multiple parameters, and is the recommended way of getting URL passed as parameters.

Comments are closed.