0
任何人都可以提供帮助。我想尽量减少我的脏代码,我在逻辑上很弱。预先感谢您..如何最小化此PHP代码
//These are all fields
$prodname = $this->input->post('prodname');
$price = $this->input->post('price');
$qty = $this->input->post('qty');
$desc = $this->input->post('desc');
$status= $this->input->post('status');
// This part I want to minimize, or any shorthand for this code??
if ($prodname != NULL && $price != NULL && $qty != NULL && $desc != NULL && $status != NULL)
$datas = $this->controller->add_product($data);
您的问题张贴在http://codereview.stackexchange.com/ – sTg
如果这是来自FORM。然后,是的,使用codeigniters form_validation,你会实现,再加上一些验证,以确保从表单提供的数据是你所追求的。 – TimBrownlaw