# Thread: updating my web sites with PHP....how??

1. what is the best way of updating my web...a guy wrote this from http://www.freewebspace.net/forums/s...p?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
It's very cool!!!
how exactly do u do it???

2. 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 =>
Code:
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. 3. 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? 4. I think because it is alot eaiser to understand then require((in_array($page,array('about','products','prices'))? $page:'error').'.txt'); 5. 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. 6. 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 => Code: 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.

7. So where do i insert this code in?

if $page = "about" { include("about.txt"); } elseif$page = "products" { include("products.txt"); }
elseif $page = "prices" { include("prices"); } 8. You place the code within your template, wherever you have data that's different for each page... 9. 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 10. 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

11. i think hes starting to get confused now.
the way there trying to explain it it goes like this:
<title>index</title>
<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. 12. Actually that gives an error you have to do this: Code: <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>