USING PHP INCLUDES

by: sion
  • go back?
  • php includes may come in handy for quick site updates so you dont have to do it with all your pages! say you wanna use this mobile friendly html grid template for an example.
    copy and paste the html code + css and save to your drive...


    now what? we're gonna divide the template into two pieces! cut out the part starting from </main> and save as header.php then replace with the rest of your code and save as footer.php. these two pieces together will create an html output.

    if you want the header, nav and footer separately, you will need three pieces: header.php, nav.php and footer.php. the more snippets you save, the more difficult its gonna be to handle.


    saved the header and footer? great! log in to your leprd cpanel (check your leprd account info), go to the file manager and create a new file named index.php on public_html.
    now edit the file and copy+paste the following code below:


    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" href="style.css">
    </head>

    <body>
    <?php include "header.php" ?>

    content goes here

    <?php include "footer.php" ?>
    </body>
    </html>

    save index.php and go to your leprd site to see the result...
    you made it! see how the output turned out? the index directly prints out your html!