|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-02 18:04 UTC] iblacksmoke at gmail dot com
Description:
------------
Is_callable function doesnt determine ability to call private method in class, even if this call made in context of class, from which you can call private function.
Test script:
---------------
class A {
public function test($method){
return (is_callable($this, $method)) ? 'yes' : 'no';
}
private function qwerty(){}
}
echo (new A)->test('qwerty');
Expected result:
----------------
yes
Actual result:
--------------
no
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 07:00:02 2025 UTC |
Please read my previous comment. Your code is wrong. Try this : class A { public function test($method){ return (is_callable(array($this, $method))) ? 'yes' : 'no'; } private function qwerty(){} } echo (new A)->test('qwerty');