You are here: Re: Managing includes « HTML « IT news, forums, messages
Re: Managing includes

Posted by Toby A Inkster on 06/28/07 07:56

Neredbojias wrote:

> I see no advantage to this. What is wrong with just inserting the path
> as you do in a link, eg: ../par_dir/somefile.html?

Firstly, consistency. If I want to include "navigation.php" from
"/index.php", with your system you have to write:

include "includes/navigation.php";

but if you want to include the same navigation menu from
"/birds/parrots.php" then you need to use:

include "../includes/navigation.php";

The path is different, you see. Now, say my site takes on more of a parrot
focus, so I decide to move "parrots.php" out of the "birds" directory and
into my site's root directory, then this breaks the include path, and I
need to change it.

Using include_path makes maintenance a lot easier. I put "navigation.php"
into a directory listed in my include path, then I can use it on
"/index.php" or "/birds/parrots.php" like this:

include "navigation.php";

without having to specify the path to it. I can then move my "parrots.php"
file about as much as I like, and don't need to make any changes to it.

This is much the same way that C programmers work. They specify the file
name of a library they want to include, but not the full or relative path
to it. They rely on the build environment to specify the location of all
the library files.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 7 days, 11:27.]

Long-Awaited Zeldman Article
http://tobyinkster.co.uk/blog/2007/06/27/zeldman-in-time/

 

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

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