question about defining constants and pear coding standards
| From: | Terra Frost | Date: | Sat, 23 Sep 2006 15:18:33 +0000 |
| Subject: | question about defining constants and pear coding standards | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-44013@lists.php.net to get a copy of this message | ||
Say I have a snippet of code like this:
<?
$a = new Some_Object();
echo $a->toString();
?>
...and that Some_Object could operate in several possible modes. Since I'd like all instances of Some_Object to work in the same mode, passing the mode info. to Some_Object every time I instantiate it is something I'd rather not do (how am I to ensure they're all going to be in the same mode, if that's how I set the mode?)
I was thinking an alternative way to do this would be to do something like...
<?
define('SOME_OBJECT_MODE',SOME_OBJECT_PHP);
$a = new Some_Object();
echo $a->toString();
?>
If SOME_OBJECT_MODE wasn't specified, a default mode could be used, by (in Some_Object.php) doing something like...
if ( !defined('SOME_OBJECT_MODE') ) {
define('SOME_OBJECT_MODE',SOME_OBJECT_PHP);
}
Anyway, the only thing I'm wondering is... would this be okay, per the Pear coding standards?