php代码求分析

WBOY
Release: 2016-06-23 14:13:43
Original
904 people have browsed it

echo join(' - ', $_GET), '<br>';  // ①$dict = array(  'area' => array('内地', '港台'),  'type' => array('动作', '爱情'),  'year' => array('2001', '2013'),);foreach($dict as $key=>$item) {  $param = $_GET;                 //②  foreach($item as $v) {    $param[$key] = $v;             //③    $t = http_build_query($param); //④    echo "<a href='/search.php?$t'>$v</a> ";  }  echo '<br>';}
Copy after login



第①句什么意思,有什么作用?
第②句把GET赋值有会用特别的用意?直接用就挺好嘛?
第③什么意思呢/
第④句什么意思呢,因为感觉好像第三句没什么意义。。。。。。谢谢


回复讨论(解决方案)

你的程序保存为 search.php 了吗?

保存了,现在没看懂您的代码如何实现的,

整段代码是为了输出 $dict 描述的3个参数的不同组合的链接,共6个,每个链接在当前请求参数的基础上,仅修改其中一个参数

1.输出当前请求参数 $_GET 在页面上
2. 后面要对 $param 进行修改,直接使用 $_GET 会导致$dict循环的第二次开始,部分参数被修改了
3. 修改其中一个参数值,比如,将area改为内地,或者type改为爱情
4. 生成修改参数后的url地址

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!