Jump to content

Request URI question


JaredRitchey

Recommended Posts

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

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

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.