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

Your name:

Reply:


Posted by Rik on 08/15/06 20:49

Chung Leong wrote:
> Rik wrote:
>> --page.php------------
>> include('head.html');
>> /* generate content */
>> include('foot.html');
>> ----------------------
>
> Agh! Drives me crazy that people keep recommending this hamfisted
> method. Doing includes in lieu of calling function is a poor way to
> program. A page header or footer is not different from other
> functionalities in your application. To reuse it,

Pardon, 'reuse'? How many heads/closing html tags do you want in a page? I
normally opt for just one, but hey, that's silly me.

> wrap it in a
> function. Example:
>
> --interface.php---
>
> <?php function printHeader() { ?>
> <html><head>...
> <?php } ?>
>
> <?php function printFooter() { ?>
> ...</body></html>
> <?php } ?>
> -----------------------
>
> Note the immediate advantage here of having the HTML within the same
> file. It's also obvious how you would implement any parameterized
> behavior--by passing parameters. To handle different page title, for
> example:
>
> <?php function printHeader($title = "Home Page") { ?>
> <html><head>
> <title><?php echo htmlspecialchars($title); ?></title>
> <?php } ?>
>
> The individual pages then pass their own titles when they need to
> override the default.

Well, that's indeed a pro to the include.
However, a con is this: If I want to change something in the head once the
project is running, I usually don't want to fiddle around in files anymore,
I want to be able to change it in an interface. While a *.php page can just
be opened and displayed in an textarea, I'm definitely more at ease working
on the plain HTML bits.

Then again, my bigger projects all have a dynamically built head section,
little to no actual static HTML content there.

Grtz,
--
Rik Wasmus

[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

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