note 56317 added to function.get-declared-classes

From: Date: Tue, 30 Aug 2005 15:17:58 +0000
Subject: note 56317 added to function.get-declared-classes
Groups: php.notes 
Request: Send a blank email to php-notes+get-94432@lists.php.net to get a copy of this message
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")); ?> ---- Manual Page -- http://www.php.net/manual/en/function.get-declared-classes.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56317 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56317&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56317&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94432) next »