Re: Re: best way to properly build an include path *regardless* from where I am calling the include?

From: Date: Mon, 06 Jul 2009 06:23:14 +0000
Subject: Re: Re: best way to properly build an include path *regardless* from where I am calling the include?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-294924@lists.php.net to get a copy of this message
Govinda wrote:
On Jul 5, 2009, at 2:33 PM, Govinda wrote:
I am confusing myself reading the docs just now. i.e.: include_path basename() and dirname() I had thought from many months ago that <?php include '/somedir/somefile.php'; ?> would include somefile.php living in somedir regardless from where in the site structure I am calling it. Now it does not seem to be doing that. What is the safest (portable) way to properly build an include path *regardless* from where in my site I am calling the include? If I understand right I can put includes in a dir/ specified by the include_path setting, but I also want to know how to do this from just within the root of my virtual server. -Govinda
in my include statement, I am now successfully using: /home/metheuser/public_html/ and am not anticipating moving this site.. but still I am thinking there must be a way to make the code bullet proof to dir/ name changes *after* the virtual server root. Or do people just stop here? Define a constant like APPLICATION_PATH in the bootstrap file of your application. Once it is defined use the paths relative to this constant. This way you can easily move your application around.
http://techchorus.net/constants and http://techchorus.net/include-path might be useful to you. -- With warm regards, Sudheer. S Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net

« previous php.general (#294924) next »