Check If URL Contains Query String with PHP

We can easy to check whether a URL contains query string or not with PHP by using parse_url() function with PHP_URL_QUERY as a component argument:

test1.php
<?php

$url = 'http://your-domain.com/post?id=1&title=hello-world';

if (parse_url($url, PHP_URL_QUERY)) {
	echo 'has query string';	
} else {
	echo 'no query string';
}

// Output: has query string

or checking $_GET if you are in current request:

test2.php
<?php

if ($_GET) {
	echo 'has query string';	
} else {
	echo 'no query string';
}

// Output: has query string