Ask Leo!

including in php and html

Search First! Then browse: Mailbag Archive | Ask Leo! Categories | Ask Leo! Archive | Newsletter

From Leo's mailbag:

> From: A Computer User
> Sent: December 26, 2005
> To: Ask Leo!
> Subject: including in php and html
>
> Leo,

> I have a mixed site: some html pages and some php pages. To
> make things easier I want to use an SSI for part of my
> content. I need an include statement that will work for both
> the html pages and the php pages. I have tried many forms of
> path and syntax but have not been able to find an include
> that will work for both types of page. Any sugggestions will
> be appreciated.

I do this all the time myself.

SSI only works within html files (or whatever files your web
server has been configured to parse for SSI). That looks
like this:

[an error occurred while processing this directive]

Depending on your server's configuration, you can also include
php files the same way:

[an error occurred while processing this directive]

remember that filename.php must be a true php file ... with ?> to invoke the php interpreter.

If you're in a PHP file, there are several ways to include files.
I typically use the "include" statement:



will include a static HTML file, and



Hope that helps.


Thanks for asking,

Leo

Article 1002