【问题标题】:Missing argument 1 for my function我的函数缺少参数 1
【发布时间】:2011-10-15 21:56:35
【问题描述】:

这是我的课:

<?php
    class eshop_log extends baseDB {


        function insert($tel,$eshop_id,$log) {

            $this->insert();
        }

    }

?>

我是这样使用它的:

$tel=  $_POST['telephone'] ;
$id= $_POST['id'] ;
$log="log";
$e_l= new eshop_log();
$e_l->insert($tel,$id,$log);

为什么我得到缺少 eshop_log::eshop_log() 的参数 1?

非常感谢

【问题讨论】:

  • 如果要访问父插入功能,请使用parent::insert()。现在你正在创建一个无限循环。

标签: php class arguments


【解决方案1】:

这与您的baseDB 课程有关。看看这个类,构造函数长什么样子?如果有类似的东西:

public function __construct($var) {

}

你需要给构造函数传递一个参数:

$e_l = new eshop_log($var);

【讨论】:

    【解决方案2】:

    里面

    function insert($tel,$eshop_id,$log)
    

    您再次调用此insert() 方法而不传递任何参数。

    您必须检查,哪些参数具有父级的insert() 方法。

    但是,调用 parent 的方法应该是这样的:

    parent::insert();
    

    【讨论】:

      猜你喜欢
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多