In the CI framework, the source code is used to determine whether a field value of post (get) data is null.

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.