View Full Version : PHP instead of SSI?
somechick 06-23-2003, 03:39 AM I saw somewhere you could use php just like ssi, but I hadn't tried it yet. (In fact I lost the link :( ) But I was wondering if it's better, and if you can update all pages at once.
With SSI I can't. I have to upload the text file into each directory and it takes awhile since I have many, many directories on my server.
Any ideas? thoughts? suggestions?
php does have the same "feature" as an SSI include...
<?
include ("filename.ext");
?>
it will react and be used just like regular SSI would.
Dude128 06-23-2003, 01:20 PM just don't forget to give all pages with that code the appropriate extension. usually it's .php, but if that doesn't work, it may be .php3, .php4, or .phtml- otherwise, the PHP code won't be processed.
and you shouldn't have to upload the file to every directory. you should be able to keep it in your main directory, then use /file.ext as the URL- that should affect all subdirectories of the main directory. or you could use the full URL of the file if you have subdirectories and sub-subdirectories and all that :)
bellportal 06-23-2003, 01:30 PM Something similar to SSI is this script from Dynamic Drive. Although your users will need to be able to support DHTML.
http://www.dynamicdrive.com/dynamicindex3/docsindocs.htm
HTH,
php is far more versatile at includes than standard serversideincludes simply because it can handle variables within the call (plus has many method calls for including - eg include, include_once, require, require_once, passthrough, fread etc)
variable includes example
$page_ref = (file_exists('folder/'.$_GET['page'].'.php')) ? $_GET['page'] : 'default' ;
include('folder/' .$page_ref. '.php');
which pulls a variable from the url (eg index.php?page=one would pull the value 'one'), checks if the file exists and then includes it.
Just to show that php is a few steps more versatile / powerful than SSI
somechick 06-23-2003, 04:38 PM Originally posted by Dude128
just don't forget to give all pages with that code the appropriate extension. usually it's .php, but if that doesn't work, it may be .php3, .php4, or .phtml- otherwise, the PHP code won't be processed.
and you shouldn't have to upload the file to every directory. you should be able to keep it in your main directory, then use /file.ext as the URL- that should affect all subdirectories of the main directory. or you could use the full URL of the file if you have subdirectories and sub-subdirectories and all that :)
I tried typing the url of the text file into the code but it wouldn't work, so I figured I had to have it in each directory. :/
Lissa 06-23-2003, 07:13 PM Php includes seem to be a little slower to me. My sis uses php includes, and according to the mood of her server, it can be pretty slow =/
Jasper 06-23-2003, 07:56 PM that is true, I sometimes use php includes and it loads the page pretty slow as in 3 seconds or something. You can also store all your information in MySQL, which is what I do. I have not really used the MySQL for any 'real' sites I made but once I get a bit better at MySQL I will.
zangerbanger 06-23-2003, 09:53 PM Originally posted by Jasper
that is true, I sometimes use php includes and it loads the page pretty slow as in 3 seconds or something. You can also store all your information in MySQL, which is what I do. I have not really used the MySQL for any 'real' sites I made but once I get a bit better at MySQL I will.
In my opinion, 3 seconds is pretty fast... :lol:
I like PHP and SSI equally because PHP has more features but is more complicated while SSI can make includes just as well as PHP and it's simple too :) .
somechick 06-24-2003, 05:23 AM So question...I can plug a url in there and not have to upload it to each directory?
Jasper 06-24-2003, 06:28 AM yes, what you do is this:
When it is in the same directory you can use this:
<?
include ("something.php");
?>
When it is in a different directory:
<?
include ("directory/something.php");
?>
And this is what I do just to make sure. Type in the full url.
<?
include ("http://www.mysite.com/directory/something.php
?>
Well, maybe it takes 5 seconds, but its slow very slow.
somechick 06-24-2003, 03:09 PM OH I thought you were saying I could use a url for SSI so I didn't have to upload the text file to each folder. I didn't realize you were talking about PHP. Sorry about that.
toosweet4u 06-25-2003, 06:35 PM adding:
ob_start('ob_gzhandler');
at the top of your pages might speed things up a little. :)
freakEgurl 06-25-2003, 11:16 PM theres always query strings. It's kidna the oppisite of includes. Your content is the include and your layout is just a page. It makes things way faster.
Jiggawot 06-27-2003, 09:11 AM Originally posted by somechick
I tried typing the url of the text file into the code but it wouldn't work, so I figured I had to have it in each directory. :/
Moo. I think there's something about remotely linking those thingies. *PHP moron* Check out http://daydreamgraphics.com/
bellportal 06-28-2003, 03:27 PM I think that my earlier post includes the quickest method. Either that or my server is just very good!
HTH,
Lissa 07-01-2003, 04:27 PM Originally posted by toosweet4u
adding:
ob_start('ob_gzhandler');
at the top of your pages might speed things up a little. :)
Why? What does that do?
ob_start is one of PHPs output buffers - basically everything in the script until ob_end_flush, ob_end_clean or the end fo the file is processed into a buffer string (ie not immediately output to browser). This string is only sent to the browser once the parser is told to do so.
now - adding ob_gzhandler to the parameters tells any *nix host (most Apache servers are *nix btw) to compress the string in a similar manner to .zip files -
gzip / tar ability of the receiving browser is part of the request headers btw - browsers that cannot handle gzipped data will not have the data compressed - all modern browsers support .gz.tar data btw.
so - string gets compiled - string gets compressed - string gets output to browser - browser decompresses string - bingo we have webpage
also - because the data is compressed it also saves bandwidth as well as increases the speed.
--------------------------
Another aside: output buffering using ob_start() also allows the sending of headers after the start of html - ie for redirecting late in a page / starting sessions late / cookies etc.
Lissa 07-01-2003, 09:35 PM So where exactly on the page would you put that?
<?php
ob_start("ob_gzhandler");
session_start();
// everything else
?>
<html>....</html>
<?php
ob_end_flush();
?>
basically - you'd want everything that needed buffering within the ob_start-ob_end calls - so ob_start would be prior to any session instantiation or cookie access calls.
another note: you don't need the ob_gzhandler parameter if you only want a part of a script buffered and can attribute the buffer to a variable with ob_get_contents (I use that for some crontab image grabs where I have to buffer against accidental browser output)
Lissa 07-02-2003, 02:23 AM I had my little sis try that on one of her pages. It loaded much faster, but now she's complaining that she can't view the source :lol:
http://www.sarahswebstuff.com/intro.php
Her site is the reason I didn't try to do my site in php, it was too slow the way she did it.
trunksstargazer 07-26-2003, 08:58 PM Is there anyway to check if your server allows ssi? I'm doing everything right on frontpage but it doesn't work there. Then I upload it to my server (litecode.net) and it still doesn't work. My administrator is not on hardly ever, due to college. Please help. Here is the code for my site:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Trunks's Dragon Ball Z Realm</title>
</head>
<body bgcolor="#000000" color="FF0000" link="#FF0000" vlink="#FF0000" text="#FF0000">
<p><img border="0" src="images/custompics/logo.jpg" width="800" height="150"></p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="800" id="AutoNumber1" height="800">
<tr>
<td align="left" width="130" valign="top" bgcolor="#999999">
<!--#include file="leftcolumn.txt" -->
<td align="left" width="505" valign="top">
<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="11" id="AutoNumber1" width="522">
<tr>
<td height="11" width="520" bgcolor="#666666"><font size="5">Updates</font></td>
</tr>
</table>
<font face="Verdana" size="3">Posted 07/26/03</font>
<p> <font face="Verdana" size="2" color="#FFFFFF">OK. I've been changing layout left
and right here but I think I'm going to keep this one. I like it more than the
last. I don't really have anything up now but I plan to change that soon. I'll
try to add the animated pics today.</font></td>
<td align="left" width="130" valign="top" bgcolor="#999999">
<!--include file="rightcolumn.txt" -->
</td>
</tr>
</table>
</body>
</html>
I really need help!
Tybalt 07-27-2003, 06:06 AM your just making that ssi a comment, might want to google it to find out more.
anyway, this is how ssi should be:
<!--#include file="testssi.inc"-->
notice the hash marK? (#)
<!--include file="testssi.inc"--> is just a plain ol' html comment.
and, I use the include function, it doesnt seem to slow down at all, you probably felt the difference because the server is either under alot of stress, or just has low resources. but because my server is quite fast, it doesnt slow down at all, if you want to see it, its in my profile. my first page alone has at least 6 includes in it and about 2 mysql queries.
trunksstargazer 07-30-2003, 12:46 AM Well, my host doesn't support SSI, but I tried PHP. I accidentally posted a new thread in the wrong place. Please help!
http://www.lissaexplains.com/forum/showthread.php?s=&threadid=38270
Thanks!
|