Closed Thread
Results 1 to 12 of 12

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

  1. #1
    Junior Member Lt.Steele is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    9

    Question

    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
    or http://www.your-lovely-host/?copyright
    It's very cool!!!
    how exactly do u do it???

  2. #2
    Senior Member jvv is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    Antwerp, Belgium.
    Posts
    191
    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.
    "Don't go knocking on death's door, ring the doorbell and run away, that really makes Death angry"

  3. #3
    Pro Member Woofcat is an unknown quantity at this point Woofcat's Avatar
    Join Date
    Nov 2000
    Location
    Chicago
    Posts
    286
    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?
    Es ist nicht leicht ein Gott zu sein

  4. #4
    FWS Addict Koolguy is an unknown quantity at this point Koolguy's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    934
    I think because it is alot eaiser to understand then require((in_array($page,array('about','products','prices'))? $page:'error').'.txt');
    koolplace\dot\com - an amazingly awesome, pointless site

  5. #5
    Pro Member KapTinKiRk is an unknown quantity at this point KapTinKiRk's Avatar
    Join Date
    Oct 2000
    Location
    CT
    Posts
    252
    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. #6
    FWS Addict atlas has a spectacular aura aboutatlas has a spectacular aura about atlas's Avatar
    Join Date
    Nov 2000
    Posts
    501
    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. #7
    Junior Member Lt.Steele is an unknown quantity at this point
    Join Date
    Nov 2000
    Posts
    9

    Post

    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"); }

  8. #8
    Pro Member Woofcat is an unknown quantity at this point Woofcat's Avatar
    Join Date
    Nov 2000
    Location
    Chicago
    Posts
    286

    Angry

    You place the code within your template, wherever you have data that's different for each page...
    Es ist nicht leicht ein Gott zu sein

  9. #9
    Member Semiel is an unknown quantity at this point
    Join Date
    Oct 2000
    Posts
    50
    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. #10
    Member psx-dude is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    California
    Posts
    37
    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. #11
    Pro Member razor is an unknown quantity at this point
    Join Date
    Oct 2000
    Location
    BFE, Pennsylvania
    Posts
    272
    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.

    religion is for people who haven't found drugs

  12. #12
    FWS Addict Koolguy is an unknown quantity at this point Koolguy's Avatar
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    934
    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>
    koolplace\dot\com - an amazingly awesome, pointless site

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts