#26924 [Bgs]: private methods can be called within a static method
| From: | mike@php.net | Date: | Fri, 16 Jan 2004 12:50:04 +0000 |
| Subject: | #26924 [Bgs]: private methods can be called within a static method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53424@lists.php.net to get a copy of this message | ||
ID: 26924
User updated by: mike@php.net
Reported By: mike@php.net
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] sniper@php.net
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] mike@php.net
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