You are here: Re: How to make the include path universal? « PHP Programming Language « IT news, forums, messages
Re: How to make the include path universal?

Posted by R. Rajesh Jeba Anbiah on 09/09/05 13:03

tom pester wrote:
> Hi,
>
> Im new to php and have a background in asp. All the help is very much appreciated.
>
> today I was using the include function in a file that itself gets included :
>
> ***************
> consumer.php : <? include "inc.php" ?>
>
> inc.php : <? include "Common/functions.php" ?>
^^^^^^^^^

Don't use include path like this. Better use relative path (eg,
../foo ../foo) or absolute path (eg, /foo). Usage of this will result in
ambiguous directory resolve (ie, it will start searching the existence
of path in include_path, etc) and will hit performance.

FWIW, I use something like:

<?php
//config.inc.php
$CFG['project_path'] = '/home/foo/foo/';
//etc etc
?>

<?php
//foo.php
require_once('../common/config.inc.php'); //relative to project
require_once($CFG['project_path'] . 'html/header.html'); //absolute
//etc etc...
require_once($CFG['project_path'] . 'html/footer.html'); //absolute
?>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация