fork download
  1. <?php
  2.  
  3. class ShopProduct{
  4. public $title = "prod";
  5. private $price = 0;
  6.  
  7. function __construct($title, $price){
  8. $this->title = $title;
  9. $this->price = $price;
  10. }
  11.  
  12. public function getPrice(){
  13. return $this->price;
  14. }
  15. }
  16.  
  17. class Saller{
  18. function sale(ShopProduct $product, $sale){
  19. return $product->getPrice() + $sale;
  20. }
  21. }
  22.  
  23. $product = new ShopProduct("dd", 50);
  24. $saller = new Saller();
  25.  
  26. echo $saller->sale($product, 0.1);
  27. echo "<br />".$saller->sale($product, 0);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
50.1<br />50