Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP3問クイズ: エラーの中身は何じゃろな?

mohira
March 30, 2019

PHP3問クイズ: エラーの中身は何じゃろな?

mohira

March 30, 2019
Tweet

More Decks by mohira

Other Decks in Programming

Transcript

  1. 1

  2. <?php class Triangle { public function __construct(int $width, int $height)

    { $this->width = $width; $this->height = $height; } } $triangle1 = new Triangle(3, 5); $triangle1->calculateArea(); //
  3. 1. unde ned method `calculateArea' for # <\Triangle:0x00007fdd0d207280> (NoMethodError) “

    “ 2. Fatal error: Uncaught Error: Call to unde ned method Triangle::calculateArea() “ “ 3. AttributeError: 'Triangle' object has no attribute 'calculateArea' “ “ 4. error: cannot nd symbol symbol: method calculateArea() location: variable u of type Triangle “ “
  4. 2

  5. private <?php class Triangle { private $width; // private public

    function __construct(int $width, int $height) { $this->width = $width; $this->height = $height; } } $triangle1 = new Triangle(3, 5); echo $triangle1->width;
  6. 2. 1. error: name has private access in Triangle “

    “ 3. unde ned method `width' for # <Triangle:0x00007f9d218d6da8 @width=0> (NoMethodError) “ “ 4. Fatal error: Uncaught Error: Cannot access private property Triangle::$width in ... “ “
  7. 3

  8. 1. 2. error: constructor User in class User cannot be

    applied to given types; required: no arguments found: String reason: actual and formal argument lists differ in length “ “ 3. `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) “ “ 4. TypeError: User() takes no arguments “ “
  9. 1.