JaredRitchey Posted May 1, 2007 Share Posted May 1, 2007 I'm trying to get this chunk of code to work but I for some reason the code fails to respond correctly. What I'm after is the entire URI with or without file name to work properly as I comment here below. I'm almost certain its my syntax in the first line shown here. case "/index.html" || $P == "/" || "$P" == "/index.php": //I WANT THIS TO WORK //case "index.php": //ONLY THIS WORKS <?php $P=$_SERVER['REQUEST_URI']; switch ($P) { // Show Three columns with advertising block on right case "login.php"; case "privacy.php"; $data = 'threecolumn2.php'; break; // Show Three columns with NO advertising blocks case "/index.html" || $P == "/" || "$P" == "/index.php": //case "index.php": $data = 'threecolumn.php'; break; // TWO COLUMNS EVERY WHERE ELSE default: $data = 'twocolumn.php'; } ?> ~ Jared Link to comment https://forums.phpfreaks.com/topic/49486-request-uri-question/ Share on other sites More sharing options...
JaredRitchey Posted May 1, 2007 Author Share Posted May 1, 2007 Forgot to explain what its for. The idea is to have a sort of variable template engine of sorts where some pages would load the third column while others would always be two columns. Some however would load a third column with a pair of advertising blocks. Each of the column files are external and use an include statement in the actual template. If I use this it doesn't work case "/index.html" || $P == "/" || "$P" == "/index.php": If I use the following its fine case "/index.php": case "/index.htm": case "/index.html": Link to comment https://forums.phpfreaks.com/topic/49486-request-uri-question/#findComment-242551 Share on other sites More sharing options...
trq Posted May 1, 2007 Share Posted May 1, 2007 <?php $P=$_SERVER['REQUEST_URI']; switch ($P) { // Show Three columns with advertising block on right case "login.php"; case "privacy.php"; $data = 'threecolumn2.php'; break; // Show Three columns with NO advertising blocks case "/index.html": case "/": case "/index.php": $data = 'threecolumn.php'; break; // TWO COLUMNS EVERY WHERE ELSE default: $data = 'twocolumn.php'; } ?> Link to comment https://forums.phpfreaks.com/topic/49486-request-uri-question/#findComment-242553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.