fork(2) download
  1. <?php
  2.  
  3.  
  4. class Worker {
  5. public $name;
  6. public $level;
  7. public $chief; // Принимает значения True or False
  8.  
  9.  
  10. function __construct($workers_name, $workers_level, $is_chief) {
  11. $name = $workers_name;
  12. $level = $workers_level;
  13. $chief = $is_chief;
  14. }
  15. }
  16. class Manager extends Worker {
  17.  
  18. protected $paid = 500;
  19. protected $pages = 200;
  20. protected $coffe = 20;
  21.  
  22. public function drinkCoffe($this) {
  23. if ($this->chief == True) {
  24. return ($coffe * 2);
  25. } else {
  26. return $coffe;
  27. }
  28. }
  29. }
  30. $Peter = new Manager('P. Stivenson', 2, True);
  31. echo drinkCoffe($Peter);
  32.  
  33. /* Стоит создать для каждого типа работника - отдельный подкласс Worker */
  34. ?>
Runtime error #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Cannot re-assign $this in /home/1RWB60/prog.php on line 24