ID: 26924
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS-2004-01-15 (dev)
New Comment:
Ah, context - you're right... :)
I was just really suprised that I may access a private method of an
object by instantiating it and calling obj->meth()
Just tested it with C# - same there :)
However, thanks for clearifying this.
Mike
Previous Comments:
------------------------------------------------------------------------
[2004-01-16 06:28:04] [EMAIL PROTECTED]
It's all about context..:)
Of course you can call private functions within the class they
belong to. But you can't call the function from 'outside'.
ie. if you tried to call 't::dont();' you'd get that error..
(or maybe I misunderstood this? :)
------------------------------------------------------------------------
[2004-01-15 13:27:44] [EMAIL PROTECTED]
Description:
------------
Private class methods can be called by instantiating an object of this
class in an static method.
Reproduce code:
---------------
<?php
class t {
private function dont() {
echo "intended?\n";
}
static function main() {
$t = new t();
$t->dont();
}
}
t::main();
?>
Expected result:
----------------
Fatal error: Call to private method t::dont() ...
Actual result:
--------------
intended?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26924&edit=1