note 47277 deleted from language.oop5.static by cmb

From: Date: Sun, 01 Sep 2019 07:26:44 +0000
Subject: note 47277 deleted from language.oop5.static by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212052@lists.php.net to get a copy of this message
Note Submitter: dmintz at davidmintz dot org ---- [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();

« previous php.notes (#212052) next »