开发者

Get the access/visibility modifier of each method

开发者 https://www.devze.com 2023-03-31 10:15 出处:网络
Is there a way to know the type (sorry if this is not the correct name) of a method inside a object? Imagin开发者_开发技巧e you have an object with 5 methods, 3 of them being public and the remaining

Is there a way to know the type (sorry if this is not the correct name) of a method inside a object? Imagin开发者_开发技巧e you have an object with 5 methods, 3 of them being public and the remaining protected / private, how can you know if a method is public?

Cheers!


You can use reflection for getting info about classes and objects. Look at http://www.php.net/manual/en/book.reflection.php

$reflection = new ReflectionClass('TestClass');
$aMethods = $reflection->getMethods(); 
var_dump($aMethods[0]->isPublic());
0

精彩评论

暂无评论...
验证码 换一张
取 消