Lt.Steele November 22nd, 2000, 10:03 what is the best way of updating my web...a guy wrote this from http://www.freewebspace.net/forums/showthread.php?threadid=475
The best way isn't using PHP. It's quite annoying to have all your html docs to php docs. A more efficient way is to make a generalized template and have a perl script build all of your pages from that template.
Less server load, as well as being "cleaner"
To atlas: You could build one(!!!!) template and create txt files(with content)...
And you could call the page like this: http://www.your-lovely-host/index.php?copyright
or http://www.your-lovely-host/?copyright
It's very cool!!!
how exactly do u do it???
jvv November 22nd, 2000, 11:59 Did he say perl and less server load ? I don't know about the second quote but PHP is AND less resource intensive AND ALOT faster than perl.
Ah, now I see what is meant with the second method. He means that determinating from which link is clicked, the same page loads different text files.
If for instance you would have links called 'about', 'products', 'prices'. And you would click on the about link, it would keep you on the index.php page, but with an argument like index.php?page=about.
Then a small piece of php =>
if $page = "about" { include("about.txt"); }
elseif $page = "products" { include("products.txt"); }
elseif $page = "prices" { include("prices"); }
(not sure this is entirly correct as I don't use includes that often)
And the content of the about.txt would be included at the place you call it.
Hope if this was of any help to you.
Woofcat November 22nd, 2000, 13:36 Better would be:
require((in_array($page,array('about','products','prices'))? $page:'error').'.txt');
This skips the multiple comparisons, uses require which is more efficient than include, and checks for errors.
Why does everyone code so inefficiently?
Koolguy November 22nd, 2000, 16:25 I think because it is alot eaiser to understand then require((in_array($page,array('about','products','prices'))? $page:'error').'.txt');
KapTinKiRk November 22nd, 2000, 18:02 I use Perl to do that exact same thing (plasticsword.com, the link to Scorpion King... it doesn't look it, but it has a lot of features).
Yes PHP is faster, but Perl is easier (i probably say that cuz I started with Perl, and just got a perl book, heh). And since I figured out how to test how fast it is, it takes 0.33 seconds to run the script, with a little load of 10 users at once, on digitalspace server.
atlas November 22nd, 2000, 21:38 I'm talking about a once through building of all the pages with a perl script (or whatever your favorite language is). Since the pages you'd be generating from a template are static anyway (you're just including a text file in PHP) instead just build them once.
So have a /raw directory with template markup (however you define your "builder script" to interpret it) and then have a script generate your static files for you from your generalized template.
That method (static pages) is less server load than having PHP grab the file and display it -- granted it is a small difference, but it makes more sense, IMHO. And for very high traffic sites it adds up.
Does that better explain what I mean?
mjk@atlascgi.com
Originally posted by jvv
Did he say perl and less server load ? I don't know about the second quote but PHP is AND less resource intensive AND ALOT faster than perl.
Ah, now I see what is meant with the second method. He means that determinating from which link is clicked, the same page loads different text files.
If for instance you would have links called 'about', 'products', 'prices'. And you would click on the about link, it would keep you on the index.php page, but with an argument like index.php?page=about.
Then a small piece of php =>
if $page = "about" { include("about.txt"); }
elseif $page = "products" { include("products.txt"); }
elseif $page = "prices" { include("prices"); }
(not sure this is entirly correct as I don't use includes that often)
And the content of the about.txt would be included at the place you call it.
Hope if this was of any help to you.
Lt.Steele November 24th, 2000, 07:08 So where do i insert this code in?
in the <head></head>?
if $page = "about" { include("about.txt"); }
elseif $page = "products" { include("products.txt"); }
elseif $page = "prices" { include("prices"); }
Woofcat November 24th, 2000, 10:48 You place the code within your template, wherever you have data that's different for each page...
Semiel November 24th, 2000, 16:09 I really dont think that php is much faster than mod_perl.
It depends on the installation i would say...
You cant compare apples with pears!
Wow, what a bad translation :)
psx-dude November 26th, 2000, 03:07 make your site in php, the layout like
HEADER
MENU
then <? include($site) >
FOOTER
then call the script script.php\?site=index.html
it will include it
razor November 26th, 2000, 09:04 i think hes starting to get confused now.
the way there trying to explain it it goes like this:
<head>
<title>index</title>
</head>
<body bgcolor="#ffffff">
whatever you want here
<?
if $page == "about" { include("about.txt"); }
elseif $page == "products" { include("products.txt"); }
elseif $page == "prices" { include("prices.txt"); }
else { include("defualt.txt"); }
?>
</body>
</html>
-you name this index.php
-you can put the stuff between the <? ?> anywhere you want.
-to link to this your url would be http://www.yourdomain.com/?page=about
-defualt would be whatever you want the people to see when they first view the page
hopefully you get it.
Koolguy November 26th, 2000, 13:21 Actually that gives an error you have to do this:
<head>
<title>index</title>
</head>
<body bgcolor="#ffffff">
whatever you want here
<?
if ($page == "about") { include("about.txt"); }
elseif ($page == "products") { include("products.txt"); }
elseif ($page == "prices") { include("prices.txt"); }
else { include("defualt.txt"); }
?>
</body>
</html>
|
|