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 Link to comment https://forums.phpfreaks.com/topic/77375-simple-php-question-from-none-programmer/ 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"; ?> Link to comment https://forums.phpfreaks.com/topic/77375-simple-php-question-from-none-programmer/#findComment-391711 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; } ?> Link to comment https://forums.phpfreaks.com/topic/77375-simple-php-question-from-none-programmer/#findComment-391718 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"; ?> Link to comment https://forums.phpfreaks.com/topic/77375-simple-php-question-from-none-programmer/#findComment-391734 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']; Link to comment https://forums.phpfreaks.com/topic/77375-simple-php-question-from-none-programmer/#findComment-391787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.