Reply to Re: Is there a more efficient way to do this?

Your name:

Reply:


Posted by Chung Leong on 08/16/06 02:01

Rik wrote:
> Chung,
> I can follow you to a certain point here, but according to your logic the
> use of more then 1 file is always useless. just one big >200K index.php,
> functions at the start, huge nested if statements further on. If you page
> changes you can just change that file("If that becomes a requirement, then
> you can change the function"). Basic programming.

If you can't back up your own argument, go change the other person's,
right?

Let us examine your suggestions again. Here's the first:

--page.php------------
include('head.html');
/* generate content */
include('foot.html');
----------------------

Now, the OP wants each individual page to have its own
title--reasonable enough. How would we do it in this scheme? It's
doable here since an include is used instead of readfile. We just need
to stick some PHP code into head.html and set a variable somewhere:

--page1.php------------
$title = "This is page 1"
include('head.html');
/* generate content */
include('foot.html');
----------------------

--page2.php------------
$title = "This is page 2"
include('head.html');
/* generate content */
include('foot.html');
----------------------

This is poor programming. The including of head.html here is
essentially a function call but one without scope. Variables used
within it could potentially overwrite those in the main file. The
parameter(s) used by it are not declared and lingers on unnecessarily
along with the those "local" to head.html.

As simple as it is, this method is not terrible convinient. Because
head.html and foot.html are not valid HTML files, you can't preview
them in the browser (or Window Explorer). If you try to edit them with
editor like Dreamweaver, it won't work. You end up having to maintain a
separate file, then spliting them into head/foot.html everytime you
make a change.

Your second suggestion is even worse:

--.htaccess------------
php_flag auto_prepend_file head.html
php_flag auto_append_file foot.html
-----------------------

A. You're locked into using Apache for no good reason. B. You need to
maintain a hash table in head.html with all the page titles. C. To get
the right title you'd need to regexp the request URI for something
unique--ugly to say the least. D. You can't redirect form these pages.
E. These pages end up with different URLs (their own and relative ones
inside them) just because they have the header/footer while others do
not.

In short, this method sucks.

[Back to original 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

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