note 56317 deleted from function.get-declared-classes by sean

From: Date: Wed, 31 Aug 2005 00:02:24 +0000
Subject: note 56317 deleted from function.get-declared-classes by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94470@lists.php.net to get a copy of this message
Note Submitter: gamehack at 1nsp1r3d dot co dot uk ---- Since I thought it would be useful for someone to have a function which returns an array with the classes defined in a file, I wrote this function: <?php function get_declared_classes_file($file) { $start = count(get_declared_classes()); include_once($file); $classes = get_declared_classes(); $end = count($classes) - 1; if(($end - $start) == -1) { // no classes defined return False; } for($i = 0, $start; $start <= $end; $start++, $i++) { $newclasses[$i] = $classes[$start]; } return $newclasses; } ?> You can test it like <?php print_r(get_declared_classes_file("file.php")); ?>

« previous php.notes (#94470) next »