Use absolute path for easier modify include path in future?

Posted by i need help on Stack Overflow See other posts from Stack Overflow or by i need help
Published on 2010-04-16T02:26:17Z Indexed on 2010/04/16 2:33 UTC
Read the original article Hit count: 413

Filed under:
|
|
|

config.php put at the root level, this file will be included in any pages.

Then at config.php

<?php
define( 'ROOT_DIR', dirname(__FILE__) );
?>

So at all other pages from different sub/a.php , sub/sub/b.php directories, when I want to include a specific file in specific location, I just need to

include( ROOT_DIR.'/include/functions.php' );

In windows server, the ROOT_DIR bring the value to C:/inetpub/vhosts/domain.com

Is this a good/secure way?

It seems like via this way, when I move the b.php to other upper level folder, I don't need to do any changes to the include file path, which is good for maintenance.

Any cons? Like SEO wise, or any other reason... What you guys think.

© Stack Overflow or respective owner

Related posts about php

Related posts about include