Php code analysis echo & nbsp; join ('& nbsp;-& nbsp;', & nbsp; $ _ GET), & nbsp; '& lt; br & gt; '; & nbsp; // & nbsp; ① $ dict & nbsp; = & nbsp; array (& nbsp; 'area' & nbsp php code analysis
Echo join ('-', $ _ GET ),'
'; // ①
$ Dict = array (
'Area '=> array ('mainland', 'Hong Kong and Taiwan '),
'Type' => array ('action', 'love '),
'Year' => array ('20140901', '20160901 '),
);
Foreach ($ dict as $ key => $ item ){
$ Param = $ _ GET; // ②
Foreach ($ item as $ v ){
$ Param [$ key] = $ v; // ③
$ T = http_build_query ($ param); // ④
Echo "$ v ";
}
Echo'
';
}
What is the meaning and purpose of the ① sentence?
In the second sentence, assign a value to GET with a special purpose? Is it good to use it directly?
What does ③ mean/
What does the fourth sentence mean? it seems that the third sentence has no significance ...... Thank you.
Share :';?? //? ① $ Dict? =? Array (?? 'Region '? =>? Array ('mainland ',? 'Hong Kong and Taiwan '),?? 'Ty... 'data-pics = ''>
------ Solution --------------------
Is your program saved as search. php?
------ Solution --------------------
The entire code segment is used to output the links of different combinations of the three parameters described by $ dict. There are 6 links in total. each link is based on the current request parameter and only one parameter is modified.
1. output the current request parameter $ _ GET on the page
2. modify $ param later. using $ _ GET directly causes the second start of the $ dict loop, and some parameters are modified.
3. modify one of the parameter values. for example, change "area" to "mainland" or "type" to "love ".
4. Generate the url address after the modified parameter