Guest User

Untitled

a guest
Jul 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. print Foo::$my_static
  2.  
  3. $classname = 'Foo';
  4. print $classname::$my_static
  5.  
  6. public function staticValue() {
  7. return self::$my_static;
  8. }
  9. }
  10.  
  11. class Bar extends Foo
  12. {
  13. public function fooStatic() {
  14. return parent::$my_static;
  15. }
  16. }
  17.  
  18.  
  19. print Foo::$my_static . "n";
  20.  
  21. $foo = new Foo();
  22. print $foo::$my_static . "n";
  23. $classname = 'Foo';
  24. print $classname::$my_static . "n"; // As of PHP 5.3.0
  25.  
  26. ?>
  27.  
  28. <?php
  29. class Foo{
  30. static $myVar="foo";
  31. public static function aStaticMethod(){
  32. return self::$myVar;
  33. }
  34. }
  35.  
  36. $foo=new Foo;
  37. print $foo->aStaticMethod();
  38. ?>
Add Comment
Please, Sign In to add comment