|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-23 23:08 UTC] tony2001@php.net
[2005-06-24 01:48 UTC] php at adaniels dot nl
[2005-06-24 09:26 UTC] php at adaniels dot nl
[2005-06-24 10:09 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 22:00:01 2025 UTC |
Description: ------------ Function is_callable will not handle private/public well from within a class. Reproduce code: --------------- <?php class X { private function getXX($value) { return "XX $value"; } function testXX() { echo (is_callable(array($this, 'getXX')) ? $this->getXX("test") : "Can't call getXX within " . __CLASS__) . "\n"; } } class Y extends X { function testXX() { echo (is_callable(array($this, 'getXX')) ? $this->getXX("test") : "Can't call getXX within " . __CLASS__) . "\n"; } } $x = new X; echo (is_callable($x, 'getXX') ? $x->getXX("test") : "Can't call getXX outside for " . get_class($x)) . "\n"; $x->testXX(); $y = new y; echo (is_callable($y, 'getXX') ? $y->getXX("test") : "Can't call getXX outside for " . get_class($y)) . "\n"; $y->testXX(); ?> Expected result: ---------------- Can't call getXX outside for X XX test Can't call getXX outside for Y Can't call getXX within Y Actual result: -------------- Can't call getXX outside for X XX test Can't call getXX outside for Y <br /> <b>Fatal error</b>: Call to private method X::getXX() from context 'Y' in <b>\\Seabert\webroot\ontwikkeling\quickbuild\test.php</b> on line <b>76</b><br />