poleposters Posted February 21, 2010 Share Posted February 21, 2010 Hi, I'm writing a script which depending on certain factors includes the appropriate template. Rather than have each template as a seperate file I thought it would be easier to combine all the templates into a single file and then weed out the appropriate section to include using a switch statement. ie include("email_template.php?template=3); would include only what was found in case 3 of the switch statement. However, this doesn't seem to be working. I get the following error An error occurred in script 'C:\xampp\htdocs\mailroom.php' on line 145: include(email_template.php?template=3) [function.include]: failed to open stream: No error Is what I'm trying to do possible using this method? Can somebody suggest a different apporach? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/192769-choose-which-parts-of-a-file-to-include-using-switch/ Share on other sites More sharing options...
premiso Posted February 21, 2010 Share Posted February 21, 2010 It is possible, but not with that method. You would have to set the variable prior to calling it. IE: $template = 3; include('template.php'); If you are using GET data, you could also do this: $_GET['template'] = 3; include('template.php'); Quote Link to comment https://forums.phpfreaks.com/topic/192769-choose-which-parts-of-a-file-to-include-using-switch/#findComment-1015468 Share on other sites More sharing options...
poleposters Posted February 21, 2010 Author Share Posted February 21, 2010 That's much easier! Thanks very much. Quote Link to comment https://forums.phpfreaks.com/topic/192769-choose-which-parts-of-a-file-to-include-using-switch/#findComment-1015469 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.