Wednesday, 15 July 2015

php - Why does if condition not working? $_SERVER['SERVER_NAME'] . $_SERVER['REQUREST_URI'] -



php - Why does if condition not working? $_SERVER['SERVER_NAME'] . $_SERVER['REQUREST_URI'] -

i trying display different word on each url.

$host = $_server['server_name'] . $_server['request_uri']; if($host=="www.thesofacompany.ca/index.php?route=information/contact"){ echo "a"; } if($host=="www.thesofacompany.ca/index.php?route=information/information&information_id=4") //this if statement isn't working.. { echo "b"; }

this if statement i've used.. sec if statement not working. programme skips sec if statement when $host has right strings..

does special character & makes not working?

just guess, string comparing case sensitive if url has wrong case, evaluate false. if hosting on iis, can problem since iis case insensitive. might want seek :

$host = strtolower($_server['server_name'] . $_server['request_uri']); if($host=="www.thesofacompany.ca/index.php?route=information/contact"){ echo "a"; } if($host=="www.thesofacompany.ca/index.php?route=information/information&information_id=4") //this if statement isn't working.. { echo "b"; }

this create sure have lowercase string compare against.

php url

No comments:

Post a Comment