note 68391 deleted from function.define by tularis

From: Date: Sun, 03 Jun 2007 09:39:09 +0000
Subject: note 68391 deleted from function.define by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127146@lists.php.net to get a copy of this message
Note Submitter: m dot blanquett at gmx dot de ---- If u have a bunch of definitions to handle, and want them to be really easy configureable, use this: definitions.xml: <definitions> <definition> <name>PROGRAM_NAME</name> <value>Foo Bar</value> </definition> <definition> <name>PROGRAM_VERSION</name> <value>0.0.1</value> </definition> </definitions> <?php $defs = simplexml_load_file('definitions.xml'); foreach($defs->definition as $def) { eval("define('{$def->name}', '{$def->value}');"); } ?> Of course you can alter the xml format as you please, maybe like this (be aware, that you then need to change the php code to the new layout of the simple xml object. <definitions> <def name="PROGRAM_NAME" value="Foo Bar" /> <def name="PROGRAM_VERSION" value="0.0.1" /> </definitions>

« previous php.notes (#127146) next »