sKunKbad Posted March 5, 2014 Share Posted March 5, 2014 Looking at the comments on the php.net page for is_callable, it would seem that is_callable didn't take visibility into account, but when I was playing around with it, it seems like it does: <?php class Foo { public function __construct(){echo 'foo';} public function a(){echo 'a';} protected function b(){echo 'b';} private function c(){echo 'c';} public function e(){echo 'e';} protected function f(){echo 'f';} } $foo = new Foo; $methods = ['__construct','a','b','c','e','f']; foreach( $methods as $method ){ if( is_callable( [ $foo, $method ] ) && strpos( $method, '_' ) !== 0 ){ call_user_func( [ $foo, $method ] ); } } echo ' should be fooae'; Did it change at some point? I've got a simple router that I'm using, and want to ensure that browsing to protected or private methods are blocked. Code similar to above would be easy to implement. Am I missing something? Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted March 6, 2014 Solution Share Posted March 6, 2014 Did it change at some point? Yes, according to the change log it changed in 5.0.5: Fixed bug #29210 (Function: is_callable - no support for private and protected classes). (Dmitry) Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted March 6, 2014 Author Share Posted March 6, 2014 Hey thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.