parboy Posted May 24, 2010 Share Posted May 24, 2010 I want to use a conditional statement to determine which include should be used based on whether the statement evaluates true or false. I think it's a matter of syntax but I haven't figured out the correct form. It seems to get more complicated with variables inside the includes. Example: <? if($issue_number=="n") { echo "<?php include 'issues/'."$nl_issue[$nl-1]".'.php'; ?>"; } else { echo <?php include 'issues/'."$nl_issue[$issue_number]".'.php'; ?>"; } ?> Link to comment https://forums.phpfreaks.com/topic/202690-conditional-includes/ Share on other sites More sharing options...
marcus Posted May 24, 2010 Share Posted May 24, 2010 Where is $issue_number coming from? <?php if($issue_number == 'n'){ include "file1.php"; }else { include "file2.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/202690-conditional-includes/#findComment-1062407 Share on other sites More sharing options...
-Karl- Posted May 24, 2010 Share Posted May 24, 2010 <? if($issue_number=="n") { Please use full PHP tags in future. Short tags are bad practise. Link to comment https://forums.phpfreaks.com/topic/202690-conditional-includes/#findComment-1062412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.