If I want to prevent a method from being called statically in PHP4, how can
I do it? So far I've tried these techniques:
<?php
class A {
var $Anotstatic;
function A() {
$this->Anotstatic = true;
}
function dynamic() {
if (!isset($this) or !is_a($this, 'A') or !(isset($this->Anotstatic) and
$this->Anotstatic))
echo "Method called statically\n";
else
echo "dynamic-only function\n";
}
function test ()
{
A::dynamic();
}
}
class B {
function test() {
A::dynamic();
}
}
$a = new A();
$a->dynamic();
A::dynamic();
$b = new B;
$b->test();
$a->test();
?>
This works for the first 3 tests (so I'm getting there), but not the fourth,
that is a dynamic method being called statically from an instance of the
same class. Is there something I've missed that will allow me to intercept
this style of call?
I know that this problem goes away in PHP5, and that the setting of $this in
static calls from other instances is not a bug (though it's the root of this
problem)!
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php