Reputation: 3037
<?php
class A
{
public $attribute1;
function operation1()
{
echo 'operation1';
}
}
$a = new A();
var_dump($a);
It shows:
object(A)[1]
public 'attribute1' => null
Question:
It outputs the property in class A
, but if I want to see the methods/functions in class A
, how could I do?
Upvotes: 1
Views: 46
Reputation: 26
You can gets the class methods' names
$class_methods = get_class_methods('A');
// or
$class_methods = get_class_methods(new A());
foreach ($class_methods as $method_name) {
echo "$method_name\n";
}
Upvotes: 1
Reputation: 30488
Use get_class_methods to view the class function names.
$class_methods = get_class_methods(new A());
foreach ($class_methods as $method_name) {
echo "$method_name\n";
}
operation1
Upvotes: 1