Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 最小化代码点火器中的函数或文件_Php_Codeigniter - Fatal编程技术网

Php 最小化代码点火器中的函数或文件

Php 最小化代码点火器中的函数或文件,php,codeigniter,Php,Codeigniter,我的问题是,如果假设视图中有多个按钮,假设它可能是15个,并且所有这些功能都不同,所以在正常情况下,我必须创建多个文件,即ajax或php文件,或者我必须在controller中创建多个函数。 是否有任何解决方案可以最大限度地减少文件或函数的数量,并在一个或两个函数或文件中实现这些功能 HTML中的 <button type="submit" name="submitForm" value="button1">Button 1</button> <

我的问题是,如果假设视图中有多个按钮,假设它可能是15个,并且所有这些功能都不同,所以在正常情况下,我必须创建多个文件,即ajax或php文件,或者我必须在controller中创建多个函数。 是否有任何解决方案可以最大限度地减少文件或函数的数量,并在一个或两个函数或文件中实现这些功能

HTML中的

    <button type="submit" name="submitForm" value="button1">Button 1</button>
     <button type="submit" name="submitForm" value="button2">Button 2</button>   
<button type="submit" name="submitForm" value="button3">Button 3</button>

谢谢你,Praveen,它工作得很好,但我有另一个问题,我们可以使用哈希标签在ci中加载视图吗?如果是,那么如何?问另一个问题兄弟。。。如果我的回答令你满意,请接受我的回答:)
$formSubmit = $this->input->post('submitForm');
if( $formSubmit == 'button1' )
   //button1 functionality
elseif( $formSubmit == 'button2' )
     //button2 functionality
elseif( $formSubmit == 'button3' )
     //button3 functionality