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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.