php split url code example
Example 1: if browser url is having query string after domain name in it check using php
$url = $_SERVER['REQUEST_URI'];
if (!strpos($url,'mysql')) {
echo 'No mysql.'; //swapped with other echo statement
} else {
echo 'Mysql exists.';
}
Example 2: how to split url in php
<?php
$url = 'http://www.example.com/news?q=string&f=true&id=1233&sort=true';
$values = parse_url($url);
$host = explode('.',$values['host']);
echo $host[1];
?>