Reply to Re: Making one HTML page from more than one file

Your name:

Reply:


Posted by Toby A Inkster on 04/19/07 08:49

Manfred Preußig wrote:

> In 'C' this would be easy to do (just '#include <filename>' at the point
> it is needed (it is recommended but not need to be at the file start))
> but can I do it in HTML and if how?

In pure HTML no, but there exist several different mechanisms for doing
what you describe with server-side scripting languages. The simplest of
these is languages is called "Server-Side Includes (SSI)" -- indeed, it is
so basic that it can barely be called a scripting language. To include a
file, you just use:

<!--#include "filename.html"-->

Easy. However, you'll need to make sure that your server supports this
feature. You don't need to worry about browser support for any particular
server-side technology though -- just server support. As you appear to
come from a C background, think of the server-side technology as being an
odd compiler extension -- if you write code that uses the odd compiler
extension, you only have to worry that your compiler supports the
extension -- you don't need to worry if the people running the
already-compiled program have a compiler that supports the extension.

Better yet would be to learn PHP, which really is a full-blown programming
language that can be embedded in web pages. Its syntax is much like C, but
it's more abstract, so you don't need to worry about memory management and
pointers and so on. Here's an example:

<p class="sum">Here is a tricky sum:<br>
<?php
$i = 123;
$j = 456;
printf('%d + %d = %d', $i, $j, $i+$j);
?>
</p>

And here's how you include a file with PHP:

<?php
include "filename.html";
?>

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

[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

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