PHP
  Home arrow PHP arrow Page 8 - Easy Application Configuration With pa...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Easy Application Configuration With patConfiguration
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-01-29

    Table of Contents:
  • Easy Application Configuration With patConfiguration
  • Plug And Play
  • Your Friendly Neighbourhood Spiderman
  • Anatomy Class
  • Version Control
  • The Write Stuff
  • Speaking Native
  • Not Your Type
  • When Time Is Money, Recycle!
  • Cache Cow
  • Link Zone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Easy Application Configuration With patConfiguration - Not Your Type


    (Page 8 of 11 )

    You'll remember, from a couple pages back, that patConfiguration supports a number of different data types for its configuration variables. This variable type can be set via the setConfigValue() method, and currently can be any one of "string", "integer", "boolean", "array" and "float".

    Here's an example which demonstrates how strings, integers and Booleans work:


    <? // include class require("patConfiguration.php"); // create patConfiguration object $conf = new patConfiguration; // set config file locations $conf->setConfigDir("config"); // set config values $conf->setConfigValue("screen.width", 500, "integer"); $conf->setConfigValue("font.face", "Verdana", "string"); $conf->setConfigValue("window.toolbar.visibility", true, "boolean"); // write file $conf->writeConfigFile("config.xml", "xml", array("mode" => "pretty")); ?>


    Here's the XML output:


    <?xml version="1.0" encoding="ISO-8859-1"?> <configuration> <path name="font"> <configValue name="face" type="string">Verdana</configValue> </path> <path name="screen"> <configValue name="width" type="int">500</configValue> </path> <path name="window"> <path name="toolbar"> <configValue name="visibility" type="bool">true</configValue> </path> </path> </configuration>


    Wanna use arrays in your configuration? patConfiguration supports those as well:


    <? // include class require("patConfiguration.php"); // create patConfiguration object $conf = new patConfiguration; // set config file locations $conf->setConfigDir("config"); // set config values $conf->setConfigValue("friends", array("Rachel", "Ross", "Monica", "Joey", "Chandler", "Phoebe"), "array"); // write file $conf->writeConfigFile("config.xml", "xml", array("mode" => "pretty")); ?>


    Here's the XML output,


    <?xml version="1.0" encoding="ISO-8859-1"?> <configuration> <configValue name="friends" type="array"> <configValue type="string">Rachel</configValue> <configValue type="string">Ross</configValue> <configValue type="string">Monica</configValue> <configValue type="string">Joey</configValue> <configValue type="string">Chandler</configValue> <configValue type="string">Phoebe</configValue> </configValue> </configuration>


    and here's the PHP output:


    <?PHP // Configuration generated by patConfiguration $config = array(); $config["friends"] = array(); $config["friends"][0] = "Rachel"; $config["friends"][1] = "Ross"; $config["friends"][2] = "Monica"; $config["friends"][3] = "Joey"; $config["friends"][4] = "Chandler"; $config["friends"][5] = "Phoebe"; ?>

    More PHP Articles
    More By Vikram Vaswani, (c) Melonfire


     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway