• 12Nov

    In PHP, it is really useful to be able to open files and get the information out of them. You can also use files you get the contents of and manipulate them like a template. By using file_get_contents I am able to get the contents of other files, manipulate and output them.
    You need flash to play this tutorial.
    This tutorial goes over the following goals:
    Getting the contents of another file
    Editing it, and returning the manipulated content
    This can be used for "cheapo" templates
    You can find this tutorial video on youtube here.

    Here are the sources used in this tutorial:
    myfile.html
    <html><head><title>blah blah</title></head>
    <body>
    Testing 123
    </body> 
    
    </html>
    toilet.php
    <?php 
    
    /**
     * @author Kloplop321.com
     * @copyright 2009
     */ 
    
    echo "toilets are fun"; 
    
    ?>
    tut024.php
    <?php
    //PHP Tutorial 024
    //$contents = file_get_contents("toilet.php");
    $contents = file_get_contents("myfile.html");
    $contents = str_replace("Testing 123","Eat my shorts", $contents); 
    
    echo $contents;
    ?>

    Here are all the php functions used in this tutorial:

    Posted by Kloplop321 @ 8:10 pm

One Response

WP_Orange_Techno

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.