Home > Article > Backend Development > CI framework, source code one-time judgment method to obtain postget data whether a certain field value is empty Source code Soraka Source code download lol source code
1. The following is the CI framework
1. Put all the fields to be received in the array
Example:
I want to receive: id, name, age, mobile and other fields
<span>$req</span> = <span>array</span>('id','name','age','mobile');
2. for loop Just judge
<span>1</span><span>for</span>(<span>$i</span> = 0;<span>$i</span> < <span>count</span>(<span>$req</span>);<span>$i</span> ++<span> ){ </span><span>2</span><span>$j</span> = <span>$this</span>->load->get_post(<span>$req</span>[<span>$i</span>],<span>true</span><span>); </span><span>3</span><span>if</span>(<span>empty</span>(<span>$j</span><span>)) </span><span>4</span><span>exit</span>(<span>$req</span>[<span>$i</span>].' 为空'<span>); </span><span>5</span><span>$data</span>[<span>$i</span>] = <span>$j</span><span>; </span><span>6</span><span>} </span><span>7</span><span>print_r</span>(<span>$data</span>);
2. Source code judgment method (no more nonsense, go directly to the code)
<span>$req</span> = <span>array</span>('id','name','age','mobile'<span>); </span><span>for</span>(<span>$i</span> = 0;<span>$i</span> < <span>count</span>(<span>$req</span>);<span>$i</span> ++<span> ){ </span><span>$j</span> = <span>$_POST</span>[<span>$req</span>[<span>$i</span><span>]]; </span><span>if</span>(<span>empty</span>(<span>$j</span><span>)) </span><span>exit</span>(<span>$req</span>[<span>$i</span>].' 为空'<span>); </span><span>$data</span>[<span>$i</span>] = <span>$j</span><span>; } </span><span>print_r</span>(<span>$data</span>);
Conclusion:
In fact, both CI framework and source code can use the source code method (2) , but in order to verify the security, we only use the first solution. The other methods called above are built-in with PHP. If you don’t understand which method, you can check the PHP help document (the master ignores it)
The above introduces the CI framework. The source code is a one-time method to determine whether a certain field value of the postget data is empty, including post and source code. I hope it will be helpful to friends who are interested in PHP tutorials.