Jump to content

Archived

This topic is now archived and is closed to further replies.

Adastra

Including contents of strings?

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Can you be more specific I dont understand what you mean to say

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Nope, still not clear. Do you mean you want to test to see if $_GET["p"] contains "name2" and "name3"?

Share this post


Link to post
Share on other sites
This would work perfectly
I 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
How about
[code=php:0]include(__FILE__."?p=name2");[/code]

Share this post


Link to post
Share on other sites
then dun use vars like $_SERVER[SCRIPT_FILENAME] use the name like in this case index.php?p=name2 [/3]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.