note 86054 rejected from language.oop5.static by thiago

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: smilesrg at ukr dot net 

----

The example doesn't work (PHP 5.2.4).
"syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM"
here: print $foo::$my_static . "\n";
and here: print $classname::$my_static . "\n";
Please, check examples before adding to documentation.

<?php
class Foo
{
    public static $my_static = 'foo';

    public function staticValue() {
        return self::$my_static;
    }
}

class Bar extends Foo
{
    public function fooStatic() {
        return parent::$my_static;
    }
}

phpinfo();
print Foo::$my_static . "\n";

$foo = new Foo();
print $foo->staticValue() . "\n";
print $foo->my_static . "\n";      // Не определено свойство my_static 

print $foo::$my_static . "\n";
$classname = 'Foo';
print $classname::$my_static . "\n"; // Начиная только с PHP 5.3.0

print Bar::$my_static . "\n";
$bar = new Bar();
print $bar->fooStatic() . "\n";

?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.