twitter




Saturday, October 24, 2009

When writing a PHP include to the web root, will this work?

define(%26quot;WebRoot%26quot;, %26quot;/path/to/the/web/root%26quot;);



include(WebRoot . %26quot;/home.php%26quot;);



include(WebRoot . %26quot;/about.php%26quot;);



include(WebRoot . %26quot;/etc.php%26quot;);



I want to make it so that the site I%26#039;m working on can be easily transferred to another web host if it needs to be, and I%26#039;m currently pointing all my includes to the root. If I have one definition in one location, it will save me a lot of work, I assume. Anything wrong/unsecure about using define() like this?



When writing a PHP include to the web root, will this work?





Forget the define. Use a sub folder of the root, or place the file to include in the root folder. For a sub folder use :



include (%26quot;/folder_name/filename%26quot;)



For the root use :



include (%26quot;/filename%26quot;)



When writing a PHP include to the web root, will this work?



I think it is a smart idea to have a Constant taht defines your path like that....I see nothing wrong with that...Just smart forethinking.

No comments:

Post a Comment