调用class [closed]时__construct出错

i have class on PHP, and when called it the function __construct($_POST) must be process.

the __construct() function define as :

// Constructor Function
function __construct($_POST){
    $this->customer       = trim($_POST['customer']);
    $this->CreateDate   = date('Y/m/d');    
}

when i called any function on class, its processed and insert to DataBase but this massage is appear :-

Missing argument 1 for Draft::__construct(), called in .... 

what wrong on my code

thankx

PHP also should throw a notice when you try to use reserved variables, like, $_POST, $_GETand $_COOKIE with "Illegal offset".

From your question, seems like you do not understand the difference between function parameters and arguments. You're already passing an argument, while it should be a parameter.

This:

function __construct($_POST){
    $this->customer       = trim($_POST['customer']);
    $this->CreateDate   = date('Y/m/d');    
}

Should be rewritten as:

function __construct($POST){
    $this->customer       = trim($POST['customer']);
    $this->CreateDate   = date('Y/m/d');    
}

And then:

$object = new YourClass($_POST);

Two things wrong:

  1. Your class constructor takes a super global as an argument.
  2. You probably don't pass an argument to the call to construct an object:

For number 2, you should be calling:

$draft = new Draft($var);

I am confused as to your intent.

$_POST is a PHP superglobal, meaning that it is available in all scopes.

If your intent is to use posted data:

There is no need to pass it as an argument

If you are passing a variable that you just so happen to call $_POST:

Change the name of the variable.

$_post is super global variable and you are using as constructor parameter change the variable name 
function __construct($post){

    $this->customer       = trim($post['customer']);
    $this->CreateDate   = date('Y/m/d');    
}

Or Second remove $_Post in constructor parameter 

function __construct(){

        $this->customer       = trim($_POST['customer']);
        $this->CreateDate   = date('Y/m/d');    
    }