Re: hierarchies

From: Date: Fri, 27 Mar 2009 19:41:35 +0000
Subject: Re: hierarchies
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-290774@lists.php.net to get a copy of this message
PJ wrote:
Jason Pruim wrote:
PJ wrote:
    
I do have a bit of a problem which has not been clearly explained in
the suggestions to my previous posts and that is the question of hierarchies. I have not yet understood how to include a file anywhere in a directory tree and have it point to the right file which may be in the top directory or, most likely, in a /lib/ directory from the file that is including. Any suggestions, or should I just make myself small and wait for the rotten eggs and spoiled tomatoes to come raining down on my head? :'(
      
Are you talking about having a file structure such as: /home /include /webroot /->images /->css /->java And you want to include a file from the include folder which is above the webroot, so doesn't have access to it? If that's the case... you just need to set the path such as: ini_set("include_path", "/home/include"); then in your PHP file you should be able to: include("mysupperfile.php"); and it should work :)
    
Not quite, but interesting option. This would be fine on my local intranet, if needed; but I don't think this would be allowed on a virtual hosted site. Actually, my problem is to use a header.php (for example) in pages in the webroot directory or any directory within (or under) webroot: / <---- webroot /site1 /files /images /lib /more files /admin
      /other_files
      /still_others
/site2 /site3 files files files... I have the header.php file in /lib . If I put include dirname(_FILE_)."/lib/header.php"; in a file under /site1, the header is displayed. If I put the same include statement in a file under /site1/files, the header is not displayed; if I change the include to ..."/../lib/header.php"; it then works. I want to be able to point to the include to the same file in the same directory without having to change the include directive. I actually use that on a shared host... Really depends on the host though... My actual file path is something more like: /home/ /myusername/ /include/ /public_html/ <---- Web root
      /file.php
      /another folder/
So all my files are inside my home folder on the server, but nothing outside of public_html is accessible from the web. As for the rest... I haven't started using dir(__FILE__) stuff yet so I won't be any help with that...

« previous php.general (#290774) next »