Advertisement
Guest User

Viselkedésminták (trait-ek) - PHP 5.4

a guest
Oct 4th, 2011
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. <?php
  2. class Hello
  3. {
  4.    public function hello()
  5.    {
  6.       echo 'Helló';
  7.    }
  8. }
  9.  
  10. trait Vilag
  11. {
  12.    public function hello()
  13.    {
  14.      echo ', Világ!';
  15.    }
  16. }
  17.  
  18. class HelloVilag extends Hello
  19. {
  20.    use Vilag;
  21. }
  22.  
  23. $o = new HelloVilag();
  24. $o->hello(); // Helló, Világ!
  25.  
  26. ?>
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement