List of PHP functions and classes

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
In Smalltalk I can get the list of the classes, methods and global
variables by querrying a global dictionary. In addition you can get the

I know in PHP one can get the list of globals via the $GLOBALS array.

But Is there a way to get the list of all the functions and
classes/methods (and arguments) currently loaded in PHP by using

Thank you

Re: List of PHP functions and classes

ImOk said the following on 15/05/2006 18:18:
Quoted text here. Click to load it
PHP 5 implements reflection, although the documentation is somewhat  
hidden away in the manual, under Classes and Objects. .

The documentation is also somewhat spartan, but with some  
experimentation you should be able to get the reflection classes to work.


Re: List of PHP functions and classes

I tried the test according to the docs. It seems the method of
ReflectionFunction->getParameters() does not work for internal
functions although it detects the parameters. Any ideas? Is this a bug
or am i doing something wrong?

print phpversion();  // 5.1.4

function baz(ReflectionFunction $a, $b = 1, $c = null) { }

// Create an instance of Reflection_Function with the
// parameter given from the command line.
$reflect = new ReflectionFunction("baz");     // works for this one.
//$reflect = new ReflectionFunction("strncmp");   // e.g. does not work
for this function

echo $reflect;

foreach ($reflect->getParameters() as $i => $param) {
       "-- Parameter #%d: %s {\n".
       "  Class: %s\n".
       "  Allows NULL: %s\n".
       "  Passed to by reference: %s\n".
       "  Is optional?: %s\n".
       var_export($param->getClass(), 1),
       var_export($param->allowsNull(), 1),
       var_export($param->isPassedByReference(), 1),
       $param->isOptional() ? 'yes' : 'no'

Re: List of PHP functions and classes


Nice to find another Smalltalker here. I guess you already have most of  
your answer. Of course you still need some list of classes. With  
phpPeanuts i have a classloading function that keeps such a list in a  
global variable. It was meant for use with php4, to look up the  
classname in original case from the lower case result php4's get_class  
function gives, but i guess you can use it for other kinds of reflection  

function includeClass($className, $dirPath='') {
   if ($dirPath && substr($dirPath, -1) != '/')
        $dirPath .= '/';

   $result = require_once("../classes/$dirPath"."$className.php");
   if ($result)
    $GLOBALS['PntIncludedClasses'][strtolower($className)] = $className;

   return $result;


Henk Verhoeven,

BTW, if you also miss the senders and implementers search, you could  
take a look at this hypercode browser:
(To my regret i did still did not find time to make it an aplha download..)

ImOk wrote:

Quoted text here. Click to load it

Site Timeline