如何使用codeigniter

时间:2017-09-18 17:27:43

标签: php codeigniter

我有一个问题,即将函数中的变量数据发送到同一控制器orderProcess中的另一个函数:

这是我的控制器orderProcess:

function endOrder(){
    $datap['invoice_pad'] = $invoice;
    $datap['date_end'] = date('d-m-Y');
    $datap['total_order'] = $grt;
    //$datap i want send to the function controller order()
}

function order(){
    //here should be $datap accepted
}

3 个答案:

答案 0 :(得分:1)

function endOrder() {

$datap['invoice_pad'] = $invoice;

$datap['date_end'] = date('d-m-Y');

$datap['total_order'] = $grt;

$this->order($datap);

}

功能顺序($ data){

echo $data['invoice_pad'];

echo $data['date_end'];

echo $data['total_order'];

}

答案 1 :(得分:0)

function endOrder(){
    $datap['invoice_pad'] = $invoice;
    $datap['date_end'] = date('d-m-Y');
    $datap['total_order'] = $grt;
    return $datap;
}

function order(){
    $datap = $this->endOrder();
}

答案 2 :(得分:0)

通常我会声明一个变量并使用它来传递所需的任何数据。但上面的回答也能够达到你想要的效果。

function __construct()
{
    $this->_datap = [];
}

function endOrder()
{
    $this->_datap['invoice_pad'] = $invoice;
    $this->_datap['date_end']    = date('d-m-Y');
    $this->_datap['total_order'] = $grt;
}

function order(){
    print_r(this->_datap);
}