954,193 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Return Functions/Methods in a class

Hi all,

I was wondering if there is a way of getting the list of functions inside a class in PHP4.

This would be similar to the ReflectionClass in php5.

Say for example I have:

[PHP]class testclass {


function func1() {
echo 'I am func1';
}

function func2() {
echo 'I am func2';
}

}

$ana = new Analysis('testclass');
$ana->getFunctionsList(); // should return array( 'func1', 'func2' );[/PHP]

Is there such a function in php4? or if someone knows of a way to get that information?

I was thinking of serializing the class, and then using regex to get the functions out of the serialized string, but there should be an easier way?

Thanks in advance :)

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Hi all,

I was wondering if there is a way of getting the list of functions inside a class in PHP4.

Try get_declared_classes() and get_class_methods(), and if needed get_defined_functions()...

With those, you can list all functions available within your actually running script.

Rotak
Newbie Poster
19 posts since May 2005
Reputation Points: 11
Solved Threads: 0
 

Thanks alot man!
:)

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You