Last active
August 29, 2015 13:57
-
-
Save ilya-dev/9856683 to your computer and use it in GitHub Desktop.
Getting all classes declared in a PHP file - various solutions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_declared_class($file) | |
{ | |
require_once $file; | |
$classes = get_declared_classes(); | |
return end($classes); | |
} | |
function get_all_declared_classes($file) | |
{ | |
$classes = get_declared_classes(); | |
require_once $file; | |
return array_diff(get_declared_classes(), $classes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment