Forum Moderators: coopster

Message Too Old, No Replies

Confused about SSI

         

OldWolf

12:20 pm on Feb 9, 2006 (gmt 0)

10+ Year Member



Hello

Im trying to learn and use SSI but as a newbie im so confused. I wonder which is best to use or is it all same thing?

 
@import
<?php require_once('header.html');?>
<?php require("header.htm");?>
<?php include('header.inc');?>
<?php include("includes/header.php");?>
<!--#include virtual="/includes/header.php"-->
include('http://www.mysite.com/includes/header.php');

coopster

2:38 pm on Feb 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



@import is for CSS.

The require [php.net] and include directives are almost identical except for the way they handle failure. Details in link.

SSI is really not necessary when you are using PHP. Yes, you could indeed use SSI along with PHP, but you really don't need to once you get a handle on the require() statement.

Personally, I almost exclusively use require_once() [php.net].

OldWolf

11:07 pm on Feb 9, 2006 (gmt 0)

10+ Year Member



Sorry for late answer

Actually i dont know php but my host dont allow me to use SSI with .html but .shtml (which i dont like that .shtml extension and prefered to have .php

I use dreamweaver and it use require_once() also and i understand that i can use require() too.

one more thing please, is it ok to use require() for my footer,header,nav bar,content etc. on the same page?

Thank you cooper

jatar_k

7:08 am on Feb 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> is it ok to use require() for my footer,header,nav bar,content etc. on the same page

yes you can. That's the way I do it, as do a lot of us.

maybe this thread about template has some examples that show how to use multiple include/require statements in a page
[webmasterworld.com...]

OldWolf

11:31 pm on Feb 10, 2006 (gmt 0)

10+ Year Member



Thank You Jatar

I will ask question later about your posts at that useful topic after i find where am i :(

i will try to explain, i use dreamweaver and it gives me the code below as default .php page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head><body></body></html>

Is this code good to start for a newbie? or is there any other suggestions.

After, iam adding my external.css

<link href="1.css" rel="stylesheet" type="text/css" />

in the body i have;

<div id="header"><?php require('includes/header.php');?></div>

Now what is the full default code should be in my header.php?.Simply i wanna have image link to my logo in it but im lost about the code i tryed some but didnt worked can someone please tell me whats the full code should be in my header.php .My image link is root/phptest/images/logo72854.png :(

OldWolf

4:30 pm on Feb 11, 2006 (gmt 0)

10+ Year Member



ok thought i figured it out now my header.php have this and working

<?php
?>

<img src="http://www.mysite.com/images/logo.png" alt="bla "/>

<?php
?>

but wonder is this a bad coding or normal?

jatar_k

6:06 pm on Feb 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, the header file doesn't even need to have a php extension if there is no php code in it. The examples you have shown don't actually have any php code so you shouldn't need the <?php and?> at all. It should work just fine with out them. The php extension is fine, doesn't really matter.

OldWolf

10:12 pm on Feb 15, 2006 (gmt 0)

10+ Year Member



Thank You again Jatar

It seems like im always forgetting to check email notification of replies :(

One last quesiton for now is it possible to hide the source of included files?

Thanks

jatar_k

11:51 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what type of source is it? just html? no, not reliably.

if it is a scripting language then the source never gets sent to the browser, only the html output

OldWolf

11:32 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



Thank you very much Jatar :)