Skip to content

PHP – Get Query String Values ($_SERVER['QUERY_STRING'])

$_SERVER variable contains the information you are searching for. Use this article to Get Query String Values passed in url in web browser using php script

Category
PHP
Versions & support
About PHP →
On this page

A Query String is a part of url accessed through web browser. Using query string we passed the argument to web pages. Using this article we will help you to how to fetch values of query string using php script.

Fetch Query String:

We can fetch url Query String values from $_SERVER array like following example.

<?php

$qs = $_SERVER['QUERY_STRING'];

?>

Parse Query String:

Now we can parse the query string and store it to an array using parse_str function.

<?php

parse_str($qs, $qs_arr);
print_r($qs_arr);

?>

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top