note 47277 modified in language.oop5.static by aidan
| From: | aidan@php.net | Date: | Mon, 15 Nov 2004 21:28:28 +0000 |
| Subject: | note 47277 modified in language.oop5.static by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80560@lists.php.net to get a copy of this message | ||
[Editor's Note: This is done for back compatability. Depending on your error level, An E_STRICT
error will be thrown.]
PHP 5.0.1 doesn't seem to mind if you call a static method in a non-static context, though it
might not be the best of style to do so.
On the other hand, PHP complains if you try to try to call a non-static method in a static context
(if your error reporting is cranked up to E_STRICT).
class Test {
static function static_method() {
echo "Here's your static method: Foo!<br />\n";
}
function static_method_caller() {
echo "static_method_caller says: ";$this->static_method();
}
function non_static() {
echo "I am not a static method<br />\n";
}
}
$t = new Test();
$t->static_method();
$t->static_method_caller();
Test::non_static();
--was--
PHP 5.0.1 doesn't seem to mind if you call a static method in a non-static context, though it
might not be the best of style to do so.
On the other hand, PHP complains if you try to try to call a non-static method in a static context
(if your error reporting is cranked up to E_STRICT).
class Test {
static function static_method() {
echo "Here's your static method: Foo!<br />\n";
}
function static_method_caller() {
echo "static_method_caller says: ";$this->static_method();
}
function non_static() {
echo "I am not a static method<br />\n";
}
}
$t = new Test();
$t->static_method();
$t->static_method_caller();
Test::non_static();
http://php.net/manual/en/language.oop5.static.php