调用 Calendar 类的 __construct 方法时没有传递 参数1和参数2例如
<?php
class Calendar{
   public function __construct($name, $age){   }
}
$obj = new Calendar();
?>
就会出这个错误。
Warning: Missing argument 1 for Calendar::__construct(), called in test.php on line 3
Warning: Missing argument 2 for Calendar::__construct(), called in test.php on line 3加个默认值就可以了
<?php
class Calendar{
   public function __construct($name='', $age=0){   }
}
$obj = new Calendar();
?>

解决方案 »

  1.   

    Warning: Missing argument 1 for Calendar::__construct(), called in test.php on line 3
    Warning: Missing argument 2 for Calendar::__construct(), called in test.php on line 3加个默认值就可以了
    <?php
    class Calendar{
       public function __construct($name='', $age=0){   }
    }
    $obj = new Calendar();
    很明显,构造函数,有参数,你调用的时候,只是实例化, 未传递参数。