fork(2) download
  1. <?php
  2.  
  3. class Counter {
  4. protected $show0;
  5. protected $show1;
  6. function __construct($arg0, $arg1) {
  7. $this->show0 = $arg0;
  8. $this->show1 = $arg1;
  9. }
  10. function Res() {
  11. return ($this->show1 - $this->show0);
  12. }
  13. }
  14.  
  15. //производный класс
  16. class Price extends Counter {
  17. private $price;
  18. function __construct($arg) {
  19. $args=func_get_args();
  20. $this->price = $arg;
  21. //конструктор базового класса
  22. parent::__construct($args[1],$args[2]);
  23. }
  24. function Sum() {
  25. return ( $this->Res() * $this->price );
  26. }
  27. }
  28.  
  29. $P = new Price(0.2436, 0, 120);
  30. echo $P->Sum(), '<br />';
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
29.232<br />