Re: Parent Limits?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 21, 2011 at 00:35, Brian Smither <bhsmither@xxxxxxxxx> wrote:
>
> The following works (three parents):
> include("../../../includes/ini.inc.php");
> require_once("../../../includes/ini.inc.php");
>
> The following works (four parents):
> include("../../../../includes/ini.inc.php");
>
> The following does not work (four parents):
> require_once("../../../../includes/ini.inc.php");

    For portability, you may want to consider dirname().  This means
that, if that file is included from another directory, the ../ calls
are dynamic (relevant to the executed file, not the included file), so
it will break unless the directories are equal in depth.

    Conversely, dirname() is static regardless of location.  Thus:

<?php include dirname(dirname(dirname(dirname(__FILE__)))); ?>

    That will work regardless of whether it's the included file or the
executed file.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux