Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
113 views
in Technique[技术] by (71.8m points)

Is there a way to dump the method definition in OOP/PHP?

Just wondering if there is any way to dump and view the function/method definition inside the class using the Object name?

I found the way to get the class name and method name as well using an instantiated object name with this function:

public function getObjectMethods(object $obj) {
   $className = get_class($obj);
   //return $className;
   return get_class_methods($className);
}

Also, I could access the properties in the class by using the var_dump; however, is there any way I could see the method/function definition inside the class?

question from:https://stackoverflow.com/questions/65713137/is-there-a-way-to-dump-the-method-definition-in-oop-php

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well AFAIK, there is no such function to see what code written on the function directly. (well, you can get the function line number and read the file with file_get_contents)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...