Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.25 KB | None | 0 0
  1. <?php
  2. class Counter{
  3.  
  4. public static $v;
  5.  
  6. public function add(){
  7. self::$v++;
  8. }
  9.  
  10. public function get(){
  11. return self::$v;
  12. }
  13. }
  14.  
  15. $a = new Counter();
  16. $a->add();
  17. $a->add();
  18.  
  19. echo $a->get();
  20.  
  21. $b = new Counter();
  22. $b->add();
  23. echo $b->get();
  24.  
  25. die;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement