Include not working with localhost?

hey all,
I’m trying to use include with a full path to my file IE: include(‘http://localhost/inc/myfile.php’);

then right after trying to see if it worked:

myfile.php IS
$var = ‘TEST’;

so my script test is:

which should show the string TEST when I run it… if I use the full path it finds the file ok but just doesn’t work. its always null


it works just fine. Any reason why it doesn’t work with the full path?

try : include(‘myfile.php’);

The php is already parsed when you include the url.

yes, I showed in my example I can get that working, its not working when trying to use the full path.

IE: include(‘http://localhost/inc/myfile.php’);

I need the full path for developing and deploying on different systems so I can dont have to worry about directory paths. thanks

It’s becuase you’re using a URL, and not a path.

You could use:

include $_SERVER['DOCUMENT_ROOT'].'/inc/';

if you need a way of easily referencing your base directory.

yes I know I’m using a URL :slight_smile:
thats what I’m trying to do because $_SERVER[‘DOCUMENT_ROOT’] doesn’t exist on IIS so I couldn’t use that for my local directory.

accodring to the manual include should be able to take a URL as an include path. so I’m not sure why it isn’t working if it is the same server path. I can see it not working for an outside side… IE include(‘’) I dont expect to get yahoo’s variables but I was hoping it would realize its the same machine and give access.