对一个php foreach的疑问,请

WBOY
Release: 2016-06-13 12:04:20
Original
939 people have browsed it

对一个php foreach的疑问,请高手指点

<br />foreach(array('_POST', '_GET') as $_request) { //array('_POST', '_GET')写在这个foreach循环中是什么意思?<br />	foreach($$_request as $_key => $_value) { //为什么前面有$$代表什么意思?<br />		$_key{0} != '_' && $$_key = XAddslashes($_value); //$_key{0}这个{0}是什么意思? <br />	}<br />}<br />
Copy after login


一个php foreach的疑问,请高手指点,不太懂,我是新手,不过我还是第一次见过这样的写法,不懂,请指点。。
------解决方案--------------------

foreach(array('_POST', '_GET') as $_request) { //array('_POST', '_GET')写在这个foreach循环中是什么意思?<br />	//array('_POST', '_GET')是数组(只是没用变量代替),当然能写在foreach里面<br />    foreach($$_request as $_key => $_value) { //为什么前面有$$代表什么意思?<br />	//$_request是_POST,那么$$_request就是$_POST,同理$_GET<br />        $_key{0} != '_' && $$_key = XAddslashes($_value); //$_key{0}这个{0}是什么意思? <br />	//$_key{0},大括号应该是以前的写法吧,可以理解为$_key[0]?<br />    }<br />}
Copy after login

------解决方案--------------------
其实就是遍历$_GET和$_POST 超全局变量,然后检查键名的第一个字符是否为_ , 如果不是则将键值经XAddslashes() 函数处理后的结果赋值给键名变量。

$_key{0} 表示取$_key 的第一个字符。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!