Display Tutorials

  Home arrow Display Tutorials arrow Page 2 - Writing a Template System in PHP
DISPLAY TUTORIALS

Writing a Template System in PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 69
    2004-01-13

    Table of Contents:
  • Writing a Template System in PHP
  • The Implementation
  • The Template File
  • The Class Skeleton
  • Constructor and Output
  • Replacing Tags
  • Including Dynamic Files
  • The Final Code
  • Tricks

  •  
     

    SEARCH CODEWALKERS

    Writing a Template System in PHP - The Implementation


    (Page 2 of 9 )

    I decided the best approach was to implement an object oriented programming solution. I envisioned something that would look similar to the following when implemented:

    <?php
    require_once("lib/template.php");

    $page = new Page("template.html");

    $page-&gt;replace_tags(array(
      
    "title" =&gt"HOME",
      
    "descript" =&gt"Welcome to my website!",
      
    "main" =&gt"dat/index.dat",
      
    "menu" =&gt"dat/menu.dat",
      
    "left" =&gt"dat/submenu.dat",
      
    "right" =&gt"dat/right.dat",
      
    "footer" =&gt"dat/footer.php"
    ));

    $page-&gt;output();
    ?>

    More Display Tutorials Articles
    More By bluephoenix

    blog comments powered by Disqus

    DISPLAY TUTORIALS ARTICLES

    - Smart Auto Refresh
    - Writing a Template System in PHP

    Developer Shed Affiliates

     



    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap