Jump to content

[SOLVED] requiring files using absolute path


sachavdk

Recommended Posts

Hi,

 

I'm having a problem here that confuses me a little.

I'm working on

http://157.176.112.4/site/en-uk/read-guestbook/index.php

and I'd like to require

http://157.176.112.4/inc/ModuleLoader.php

but using

require_once( "/inc/ModuleLoader.php" );

gives me an error:

 

PHP Warning: main(/inc/site.php) [function.main]: failed to open stream: No such file or directory in J:\WEBSERVER\www\beta\site\en-uk\read-guestbook\index.php on line 2 PHP Fatal error: main() [function.require]: Failed opening required '/inc/site.php' (include_path='.;C:\php5\pear') in J:\WEBSERVER\www\beta\site\en-uk\read-guestbook\index.php on line 2

 

file_exists( "/inc/ModuleLoader.php" ); fails as well.

using require_once( "../../../inc/ModuleLoader.php" ); does work.

any suggestions?

 

thanks

 

edit: I can't use relative paths because the structure of the <site> class isn't really written to deal with this.

i dont know it your work so its hard to  tell but in each folder you have to define the path that need to be include in every page

 

you said this works

using require_once( "../../../inc/ModuleLoader.php" ); does work.

 

then define them

define it like

define('folder1', "../../../inc/" );

 

now you can use folder1 to determine the location you need

Archived

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

×
×
  • Create New...

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.