Why is this legal in PHP?
<?php class Foo { public function test() { echo "hello\n"; } } Foo::test(); ?>
test () is a non-static function, but I can access it without an instance.
I believe in this because of backward compatibility. In PHP4, you did not have a static keyword for methods (still looking for links, but for now this is all I found http://us2.php.net/manual/en/language.oop5.static.php ). Thus, PHP4 code can work without problems.
It is best to declare your static functions as such, and if you enable E_STRICT, you will see a notification about this.
error_reporting(E_ALL | E_STRICT);
: , , http://bugs.php.net/bug.php?id=34990 http://bugs.php.net/bug.php?id=47891.
, , , , $this , .
$this
PHP:
E_STRICT.
, E_STRICT. PHP .
, .
Source: https://habr.com/ru/post/1723166/More articles:lambda-gtk negative pointer - lispGiving focus to a child window in IE8 - javascriptRails migration generator does not generate columns - ruby โโ| fooobar.comCan chart points on Google Maps be calculated based on the number of hours in seconds - javascriptvb.net dataTable / DataGridView search / sort - sortingAccess GPS data from .Net Winform application - c #IE8 Class Pseudo-Class and Sibling Selector - cssPreloader in actionscript 3 - Original error in getDefinition () - actionscript-3Fast Javascript String Replacement - javascriptHow to handle the "order" of a list of items in DB (php) - databaseAll Articles