/    Sign up×
Community /Pin to ProfileBookmark

Why use PHP to ‘include’ logo/menu code to put on each page

If you want the same logo/menu to go on each page, you can do this with SSI or PHP. I have PHP working, using an ‘include’ statement to pull up menu.php file into the html page. I first tried to use SSI but it would not work. I contacted the server admin and he now says he added this and SSI should now work. Before I go back and re-write the pages to try it… should I? Do you think PHP is better for this or SSI?

Goal being to build sites so that you don’t have to change every single page when you change something like a menu that should be the same for every page.

to post a comment
PHP

15 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcherySep 24.2006 — what's SSI? Do you mean SSL?
Copy linkTweet thisAlerts:
@ronverdonkSep 24.2006 — I would prefer PHP. In PHP you have more variations for including files, i.e.

require

include

require_once

include_once

Have a look at the PHP manual [URL=http://nl3.php.net/manual/en/language.control-structures.php]PHP control structures[/URL] to see what options you have more then with SSI.

Ronald ?
Copy linkTweet thisAlerts:
@dodo1Sep 24.2006 — include in PHP is simple as count to 3.

There is no need to look after easy way...
Copy linkTweet thisAlerts:
@Duke_WillauthorSep 24.2006 — what's SSI? Do you mean SSL?[/QUOTE]

server side includes
Copy linkTweet thisAlerts:
@NogDogSep 24.2006 — I don't think you'll find either method has a significant enough difference in performance to affect your choice. PHP's main advantage will be if you want to do something programmatic. For instance, you might include a file which defines a function "head" to output the beginning of each page. It would include input params for the page title, keywords, and description. Then you could tailor each of those attributes on a per page basis:
[code=php]
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/includes/head.php';
head('Page Title', 'list,of,keywords', 'This is the description.');
?>
[/code]
Copy linkTweet thisAlerts:
@felgallSep 24.2006 — what's SSI? Do you mean SSL?[/QUOTE]

Server Side Includes are nothing at all like Secure Socket Layer - they are two completely different things.

SSI will be fractionally faster than PHP in delivering the web page since all it can do is to insert the code from the include member into the page (but for most practical purposes this will be so small a difference you would need to be timing the microseconds to notice it. PHP is a far more powerful language that will allow you to add other features to your page. If you have PHP working then you have no reason to swap back to SSI.
Copy linkTweet thisAlerts:
@sitehatcherySep 25.2006 — Can someone give an example of server side includes?
Copy linkTweet thisAlerts:
@pcthugSep 25.2006 — <i>
</i>&lt;!--#include virtual="/footer.html" --&gt;

Will include [I]footer.html[/I] in your page. For further information see the [url=http://httpd.apache.org/docs/1.3/howto/ssi.html]Apache Introduction to Server Side Includes[/url].
Copy linkTweet thisAlerts:
@NogDogSep 25.2006 — I think some Apache configurations require that the included file have a suffix of ".shtml". (Or am I misremembering: it's been a long time since I've used SSI?)
Copy linkTweet thisAlerts:
@pcthugSep 26.2006 — I think some Apache configurations require that the included file have a suffix of ".shtml". (Or am I misremembering: it's been a long time since I've used SSI?)[/QUOTE]
No, the included file may have any extension (in reason). It's only the file with the SSI code in it that requires a .shtml suffix.
Copy linkTweet thisAlerts:
@NogDogSep 26.2006 — No, the included file may have any extension (in reason). It's only the file with the SSI code in it that requires a .shtml suffix.[/QUOTE]
Ah, thanks, that sounds right. I knew there was a "shtml" somewhere in the mix. ?
Copy linkTweet thisAlerts:
@pcthugSep 26.2006 — ?
Copy linkTweet thisAlerts:
@sitehatcherySep 26.2006 — Can you use SSI on IIS servers, or can you use an IIS command in your code to include files?
Copy linkTweet thisAlerts:
@NogDogSep 26.2006 — Can you use SSI on IIS servers, or can you use an IIS command in your code to include files?[/QUOTE]
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q203064
Copy linkTweet thisAlerts:
@sitehatcherySep 26.2006 — Thanks!
×

Success!

Help @Duke_Will spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...