954,180 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can includes have a variable?

I tried to write include "http://".$_SERVER["SERVER_NAME"]."/lol.php" and it didn't include it?

GigsD4X
Light Poster
31 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

If you are trying to include from the root directory of your site, use:

include $_SERVER['DOCUMENT_ROOT']."/lol.php";
chrishea
Nearly a Posting Virtuoso
1,427 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Yes it can, just a guess here, but it might be a typo, the semicolons are missing at the end of the statement.

For further reference:
Include

Triztian
Light Poster
28 posts since Sep 2009
Reputation Points: 10
Solved Threads: 4
 

If you are trying to include from the root directory of your site, use:

include $_SERVER['DOCUMENT_ROOT']."/lol.php";


Hmm.. That didn't seem the work, it's probably because I'm on a subdomain?

GigsD4X
Light Poster
31 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

Oh I see what's going on! It isn't grabbing the code because SERVER_NAME is using the full path! But I can't use DOCUMENT_ROOT =\

GigsD4X
Light Poster
31 posts since May 2010
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You