PHP Classes

File: example.ScriptParser.php

Recommend this page to a friend!
  Classes of Cornelius Bolten   Lib Script Parser   example.ScriptParser.php   Download  
File: example.ScriptParser.php
Role: Example script
Content type: text/plain
Description: example-file
Class: Lib Script Parser
Parse hierarchic configuration files into arrays
Author: By
Last change:
Date: 20 years ago
Size: 1,598 bytes
 

Contents

Class file image Download
<?php

   
/**
    * $RCSfile: example.ScriptParser.php,v $
    * @author $Author: Cornelius Bolten $
    * @version $Revision: 1.2 $
    *
    *
    * @description:
    * - this is the example-file for libScriptParser by
    * Cornelius Bolten
    * - in this example, a simple script-file is loaded,
    * parsed, and put out to user.
    *
    * @required:
    * - no requirements
    *
    * --> these packages can be retrieved via http://www.phpclasses.org/browse/package/1617.html
    *
    * so now..here we go!
    *
    **/
   
    /**
    * include library
    */
   
include_once("lib.ScriptParser.php");
   
$Parser = new ScriptParser();
   
$Parser->setScriptFile("myscript.txt");
   
   
   
/**
    * parse script myscript.txt
    * and output some values if parsing is successfull
    */
   
if($settings = $Parser->parse()) {
        echo
"<b>sectionname:</b> ". $settings["section.name"] ."<br>";
        echo
"<b>page id:</b> ". $settings["section.page.id"] ."<br>";
        echo
"<b>page header:</b> ". $settings["section.page.header"] ."<br>";
        echo
"<b>page CSS color:</b> ". $settings["section.page.css.color"] ."<br>";
        echo
"<b>page CSS font-family(default):</b> ". $settings["section.page.css.font.family.default"] ."<br>";
        echo
"<b>page CSS font-family(alternative):</b> ". $settings["section.page.css.font.family.alternative"] ."<br>";
        echo
"<b>page CSS font-size:</b> ". $settings["section.page.css.font.size"] ."<br>";
        echo
"<b>page CSS font-weight:</b> ". $settings["section.page.css.font.weight"] ."<br>";
        echo
"etc.";
    } else {
        echo
"error while parsing script";
    }
   
   
/**
    * we're done ;-)
    */
?>