php help

jpsj82

Senior member
Oct 30, 2000
958
0
0
i need some help with php. i want to include a file and have that file based on some variable, like the following.

if i have
$id = 'my-test';

i want to include the following
include = 'http://www.mysite.com/~test1/my-test.inc';

how do i do this? is there some string append function in php i can use? because the include line is already in the php quotes i couldn't just put <?php echo $id ?> where i wanted it.

anyone have any ideas, thanks in advance.
 

RSMemphis

Golden Member
Oct 6, 2001
1,521
0
0
include = "http://www.mysite.com/~test1/" . $id;

Edit: actually, in your case: include = "http://www.mysite.com/~test1/" . $id . ".inc";

HTH

 

jpsj82

Senior member
Oct 30, 2000
958
0
0


<< include = "http://www.mysite.com/~test1/" . $id;

HTH
>>

ok, i will try this, but just looking at this i will assume it doesn't add the .inc afterwards. My guess is that i just have to do the following:

include = "http://www.mysite.com/~test1/" . $id . ".inc";

i'll try it now.
 

jpsj82

Senior member
Oct 30, 2000
958
0
0
hmm

Parse error on the following

include = "'http://www.mysite.com/~test1/" . $id . ".inc";

any idea what is wrong?
 

jpsj82

Senior member
Oct 30, 2000
958
0
0


<< you have a single and a double quote before http >>

not sure how that got in there - but that is not in my real code
 

jpsj82

Senior member
Oct 30, 2000
958
0
0
ok now i am an idiot - php syntax does not have an = symbol.

so correctly it would be wrote as

include "http://www.mysite.com/~test1/" . $id . ".inc";

thanks everyone
 

RSMemphis

Golden Member
Oct 6, 2001
1,521
0
0
Ah, man, you got me.

I did not even check.

It's:
include "http://www.mysite.com/~test1/" . $id . ".inc";

I stupidly copied your equal sign.


BTW, there is no () involved
 

jpsj82

Senior member
Oct 30, 2000
958
0
0


<< $id="http://www.mysite.com/~test1/my-test.inc";
include($id);
>>

thanks for the help, but the problem with this is it might not be my-test it could be my-test2 or my-test3 or anthing. So i need to use the method that RSMemphis gave me.