从控制器返回一个值而不是数组来查看php codeigniter

时间:2010-04-19 10:35:42

标签: php codeigniter

我在我的控制器中使用它,

function phpcalview()
{
    $year = $this->input->post('yearvv');
    $year1 = $year+1;
    //echo $year1;
    $this->load->view('phpcal',$year1); 
}

如何$year1重视我的观看次数phpcal,并在文本框中获取该值yearvv

2 个答案:

答案 0 :(得分:2)

function phpcalview()
{
    $year = $this->input->post('yearvv');
    $data['year1'] = $year+1;
    $this->load->view('phpcal',$data); 
}

在视图中:

echo $year1;

答案 1 :(得分:1)

如果您想“在文本框yearvv中获取该值”,请将其放在您的视图中:

<input type="text" name="yearvv" value="<?=$year1?>" />