frhs00 Posted November 14, 2007 Share Posted November 14, 2007 I am wanting to do specific server side includes that are conditional on a variable. I don’t know php, but looking for code to select a different server side include based on a variable. I am looking for php code to fullfill the logic below: <? If varible=a include ("stuffa.php"); else If varible=b include ("stuffb.php"); else If varible=c include ("stuffc.php"); else include ("stuffd.php"); ?> Thanks for your help, David Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 <?php if ($var == 'a') include "stuffa.php"; else if ($var == 'b') include "stuffb.php"; else if ($var == 'c') include "stuffc.php"; else include "stuffd.php"; ?> Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted November 14, 2007 Share Posted November 14, 2007 <?php switch($variable){ case a: //do stuff break; case b: //do stuff break; case c: //do stuff break; default: //default action break; } ?> Quote Link to comment Share on other sites More sharing options...
frhs00 Posted November 14, 2007 Author Share Posted November 14, 2007 Working from below, how would I define the $var, so it can run through the options? Thanks, David <?php if ($var == 'a') include "stuffa.php"; else if ($var == 'b') include "stuffb.php"; else if ($var == 'c') include "stuffc.php"; else include "stuffd.php"; ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 It all depends on where you want the variable coming from. If the variable is coming from the URL, you would do $var = $_GET['var']; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.