In the CI framework, the source code is used to determine whether a field value of post (get) data is null. In the CI framework, the source code can be used to determine whether a field value of post (get) data is null at a time, cipost 1. below is the CI framework 1. put all the fields to be received in the array for example: CI framework, one-time source code judgment get post (get) whether the data has a field value that is null, cipost
I. The following is the CI framework
1. put all the fields to be received in the array.
Example:
I want to receive fields such as id, name, age, and mobile.
$req = array('id','name','age','mobile');
2. for loop judgment.
1 for ($ I = 0; $ I <count ($ req); $ I ++) {2 $ j = $ this-> load-> get_post ($ req [$ I], true); 3 if (empty ($ j )) 4 exit ($ req [$ I]. 'blank'); 5 $ data [$ I] = $ j; 6} 7 print_r ($ data );
II. source code judgment method (no nonsense, directly go to the code)
$ Req = array ('id', 'name', 'age', 'mobile'); for ($ I = 0; $ I <count ($ req ); $ I ++) {$ j =$ _ POST [$ req [$ I]; if (empty ($ j) exit ($ req [$ I]. 'blank'); $ data [$ I] = $ j;} print_r ($ data );
Conclusion:
In fact, both the CI framework and the source code can use the source code method (2). However, to verify the security, use the first method. the other methods mentioned above are provided by php. which method does not understand, you can check the PHP help documentation (ignored)
Whether the value of a field in get data is null. cipost 1. The following is the CI framework 1. put all the fields to be received in the array for example :...