fork download
  1. <?php
  2.  
  3. class Product
  4. {
  5. public $name;
  6. public $price;
  7. public $weight;
  8. public $border;
  9. public $bg;
  10. public $nameFS;
  11. public $priceWeightFS;
  12. public $NDS;
  13.  
  14. public function __construct($name, $price, $weight, $border, $bg, $nameFS=20,$priceWeightFS=14, $NDS)
  15. {
  16. $this->name = $name;
  17. $this->price = $price;
  18. $this->weight = $weight;
  19. $this->border = $border;
  20. $this->bg = $bg;
  21. $this->nameFS = $nameFS;
  22. $this->priceWeightFS = $priceWeightFS;
  23. $this->NDS = $NDS;
  24. }
  25.  
  26. public function printInfo(){
  27. echo "<div style='border: {$this->border}; background: {$this->bg}; font-size: {$this->priceWeightFS}px'>
  28. <h2 style='font-size: {$this->nameFS}px'>{$this->name}</h2>
  29. <p>{$this->price}</p>
  30. <span>{$this->weight}</span>
  31. </div>";
  32. }
  33. }
  34.  
  35. $test = new Product('Яблоки','120','12', '2px solid black', 'white');
  36. $test->printInfo();
  37.  
  38. ?>
  39.  
  40.  
Runtime error #stdin #stdout #stderr 0.01s 24752KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Product::__construct(), 5 passed in /home/1cVG5N/prog.php on line 35 and exactly 8 expected in /home/1cVG5N/prog.php:14
Stack trace:
#0 /home/1cVG5N/prog.php(35): Product->__construct('\xD0\xAF\xD0\xB1\xD0\xBB\xD0\xBE\xD0\xBA\xD0\xB8', '120', '12', '2px solid black', 'white')
#1 {main}
  thrown in /home/1cVG5N/prog.php on line 14