Parsing a URL

    • Parsing a url

    • Echo a url. Here is an example of a webpage with a query string attached:
      $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'];
      echo $url;

      example result:

    • Echo just the query string of the url:
      echo $_SERVER['QUERY_STRING'];

      example result: f2fc1b9ecc1986f34588fd=listAudience&modulemail

    • Echo just some portion of the query string of the url, in this case everything after the ‘=’
      echo preg_match('/listAudience&modulemail$/i', $_SERVER['QUERY_STRING'];

      example result: listAudience&modulemail

      courtesy of: