http://www.youarebug.com/forum.php?mod=viewthread&tid=105&page=1&extra=#pid142
この投稿
CodeIgniterMVCMVC
CodeIgniterCI_02WelcomeindexCIMVCCIconfigroutes.php リーリー
に変更します。
リーリー
リーリー
CI_ControllerPHP?>CI
viewsphpcalculate_view.php リーリー
リーリー
リーリー
と書きます。 リーリー リーリー
<span $data</span> = <span array</span>('num1' => 1, 'num2' => 2, 'op' => +, 'result' => 3);
<span echo</span> <span $num1</span>." ".<span $op</span>." ".<span $num2</span>." = ".<span $result</span>."<br />";
<span function</span> <span count</span><span () { </span><span //</span><span 使用输入类接收参数</span> <span $num1</span> = <span $this</span>->input->post('num1'<span ); </span><span $op</span> = <span $this</span>->input->post('operate'<span ); </span><span $num2</span> = <span $this</span>->input->post('num2'<span ); </span><span if</span> (<span is_numeric</span>(<span $num1</span>) && <span is_numeric</span>(<span $num2</span><span )) { </span><span //</span><span 如果两个数输入均为数字,则调用calculate_model模型下的count方法</span> <span $result</span> = <span $this</span>->calculate_model-><span count</span>(<span $num1</span>, <span $num2</span>, <span $op</span><span ); </span><span //</span><span 生成要传给视图的数据</span> <span $data</span> = <span array</span>('num1' => <span $num1</span>, 'num2' => <span $num2</span>, 'op' => <span $op</span>, 'result' => <span $result</span><span ); </span><span //</span><span 加载视图</span> <span $this</span>->load->view('result_view', <span $data</span><span ); } }</span>
data MVCCI
CIMVCMVCURIajax http://www.youarebug.com/forum.php?mod=viewthread&tid=105&page=1&extra=#pid142