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

WBOY
Release: 2016-07-29 08:49:36
Original
1021 people have browsed it

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');
Copy after login

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>);
Copy after login

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>);
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template