Re: A question that has been bugging me..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Pruim wrote:

On Aug 16, 2007, at 11:56 AM, Daniel Brown wrote:


    Otherwise, is there any reason you're not just doing something
like the following?

<?
    include('templates/header.html');
    // Data goes here
    include('templates/footer.html');
?>


Because I came as a HTML person into PHP and didn't even think about being able to include my headers, footers, nav etc in the php file... Just include the php in the html... I'll look into that later today if I have time :)


One thing to be aware of is that PHP's include() needs the full directory path whereas the SSI parser takes it from docroot (if using "virtual"). So, if you had something like this in your shtml file:

<!--#include virtual="/includes/interface/top.html" -->
<title>foo</title>
</head>
<body>
<div id="wrapper">
<!--#include virtual="/includes/interface/banner.html" -->
<!--#include virtual="/includes/interface/nav.php" -->
<div id="content">

you can change it husly for a PHP script:

<?php
// some PHP stuff here, perhaps
include "${_SERVER['DOCUMENT_ROOT']}/includes/interface/top.html";
// note the double-quotes above
?>
<title>foo</title>
</head>
<body>
<div id="wrapper">
<?php
include "${_SERVER['DOCUMENT_ROOT']}/includes/interface/banner.html";
include "${_SERVER['DOCUMENT_ROOT']}/includes/interface/nav.php";
?>
<div id="content">

(where top.html contains CSS links, script tags, etc.)

So, in order to create any of your PHP pages, you can simply copy one of the SHTML files and make those simple changes to the include calls.

brian

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux