the if condition is not executing and unable to print result, there is a blank page.

<?php
$url = $_SERVER['HTTP_HOST'];
$url_length = strlen($url);
if(substr($url, 0, 4 )  = 'www.') {
$url_length = $url_length - 4;
$url = substr($url, 4, $url_length);
}
echo $url_length.'<br />'.$url;  
?>

Hi,

you have to use the comparison operator ==, at the moment you are using the assignment operator =.

To expand on cereal's comment. You may also look into the types of comparison operators.
== is Equals. Using this operator will only compare the value.
=== is Identical. This operator will compare type and value of the variable.

=== Should be used on strings.

Member Avatar for diafol

If you're using urls - you may find parse_url useful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.