将数据推送到显示错误的页面


pushing data to a page showing error

我正在使用代码点火器控制器将数据推送到页面

public function trial(){
            /* after commiting now show them the next page which will directly allow them to invest */
                            $usertable =$this->user_profile->getUserTable();               
                            $userId = $usertable['ORIG_ID'];
                            $facebookId = $this->Facebook->getUser();
                            $sidebarData = array(
                                'userName' => $this->user_profile->getUserName(), 
                                'facebookId' => $facebookId, 
                                'caller' => 'investment_bucket'
                        );
                         $headerData = array(
                            $this->history->getPreviousPageInArray(),
                            'userName' => $this->user_profile->getUserName(),
                            'facebookId' => $facebookId 
                        );
                            $investAmount = 100;
                            $loanPeriod = 60;
           $investdata = array(
                                'investAmount' => $investAmount ,
                                'loanPeriod ' => $loanPeriod,
                                'pathName' => 'invest'
                            );
                            $this->load->view('header', $headerData);   
                            $this->load->view('borrower_sidebar_view', $sidebarData);
                            $this->load->view("invest_created_basket_view",$investdata);
                            $this->load->view('footer');  
        }

但在加载页面上显示,

遇到PHP错误严重性:注意消息:未定义变量:loanPeriod文件名:views/invest_created_basket_view.PHP线路编号:9

这是我加载数据的地方。

<input type ="text" value="<?php echo $investAmount; ?>" 
<input type ="text" value="<?php echo $loanPeriod ; ?>"

我搞不清问题出在哪里。

您有一个简单的打字错误。它是数组关键字'loanPeriod ' 中的尾随空格

$investdata = array(
    'investAmount' => $investAmount ,
    'loanPeriod' => $loanPeriod,
    'pathName' => 'invest'
);