In the CI framework, the source code is used to determine whether a field value of post (get) data is null.
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)