Adastra Posted August 1, 2006 Share Posted August 1, 2006 I have a document structured like this: [code=php:0]<?if ($_GET['p'] == "name1") {my contents } elseif ($_GET['p'] == "name2") {my contents } elseif ($_GET['p'] == "name3") {my contents }?>[/code]and so on. But now I need a string which gives me the contents of two of those strings, which somewhat includes the content of two of the strings in a new one together. [code=php:0]elseif ($_GET['p'] == "name_all") {content of name2 and name3}[/code]How can I do that? include() doesn't work, and I've tried various other stuff with echo, $_GET and print, but nothing works! I'm sure you can easily do this with some function I don't know about. Thanks in advance :) Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/ Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 Can you be more specific I dont understand what you mean to say Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66905 Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 I want something like this: [code=php:0]elseif ($_GET['p'] == "name_all") {content of ($_GET['p'] == "name2") and ($_GET['p'] == "name3")}[/code]I don't know how to explain it better. Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66906 Share on other sites More sharing options...
king arthur Posted August 1, 2006 Share Posted August 1, 2006 Nope, still not clear. Do you mean you want to test to see if $_GET["p"] contains "name2" and "name3"? Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66925 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 This would work perfectlyI get wat you mean[code]elseif ($_GET['p'] == "name_all"){include("$_SERVER[SCRIPT_FILENAME]?p=name2");include("$_SERVER[SCRIPT_FILENAME]?p=name3");}[/code]See its simple if you use get to get the content you can include the same script with different get parameters.:)hope dat helps Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66938 Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 Hmmpf, it's not working, I get this error (multiple times): Warning: main(): Failed opening '/var/www/index.php?p=page3' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/unisys-outsourcing/index.php on line 5 Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66992 Share on other sites More sharing options...
Ifa Posted August 1, 2006 Share Posted August 1, 2006 How about [code=php:0]include(__FILE__."?p=name2");[/code] Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-66993 Share on other sites More sharing options...
Adastra Posted August 1, 2006 Author Share Posted August 1, 2006 Nope, same error there :/ Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-67007 Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 then dun use vars like $_SERVER[SCRIPT_FILENAME] use the name like in this case index.php?p=name2 [/3] Link to comment https://forums.phpfreaks.com/topic/16188-including-contents-of-strings/#findComment-67009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.