note 59305 added to function.constant

From: Date: Fri, 02 Dec 2005 15:18:34 +0000
Subject: note 59305 added to function.constant
Groups: php.notes 
Request: Send a blank email to php-notes+get-99456@lists.php.net to get a copy of this message
If you have multiple classes doing the same thing, e.g. a directory listing, and want to make it user-configurable, you can use constant() like so: --------- <select name="x"> <?php foreach ( $classes as $classname ) { include_once('classes/directoryindex/'.$classname.'.php'); printf("<option value='%s'>%s</option>\n", constant($classname.'::ID'), constant($classname.'::Name') ); } ?> </select> --------- then just add the consts "ID" and "Name" to each class. ---- Manual Page -- http://www.php.net/manual/en/function.constant.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59305 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59305&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59305&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99456) next »