The code is as follows:
Load ("Links.xml"), $x = $xmlDoc->getelementsbytagname (' link '),//get the Q parameter from url$q=$_get["Q"];//lookup All links from the XML file if length of q>0if (strlen ($q) > 0) {$hint = "", for ($i =0; $i < ($x->length); $i + +) {$y = $x->item ($i)->getelementsbytagname (' title '); $z = $x->item ($i)->getelementsbytagname (' url '); if ($y->item (0)->nodetype==1) {//find A link matching the search text if (Stristr ($y->item (0)->childnodes- >item (0)->nodevalue, $q)) {if ($hint = = "") {$hint = "item (0)->childnodes->item (0)->nodevalue. "' target= ' _blank ' >". $y->item (0)->childnodes->item (0)->nodevalue. ""; } else {$hint = $hint. "
Item (0)->childnodes->item (0)->nodevalue. "' target= ' _blank ' >". $y->item (0)->childnodes->item (0)->nodevalue. ""; }}}}}//Set output to ' no suggestion ' if no hint were found//or to the correct valuesif ($hint = = "") {$response = " No suggestion "; }else {$response = $hint;}//output the Responseecho $response;? >
In this piece of code:
if ($hint = = "") { $hint = "Item (0)->childnodes->item (0)->nodevalue. " ' target= ' _blank ' > '. $y->item (0)->childnodes->item (0)->nodevalue. ""; } else { $hint = $hint. "
Item (0)->childnodes->item (0)->nodevalue. "' target= ' _blank ' > '. $y->item (0)->childnodes->item (0)->nodevalue. ""; }
Question 1: $hint=0 has not been defined before, why do you want if ($hint = = "")?
Question 2: Title $hint not = 0, what does the following code do?
Reply to discussion (solution)
where $hint = 0?
DECLARE $hini= "" is for storage purposes, the first cycle when the $hini is not a value, but the second cycle when there is AH
where $hint = 0?
$hint = ""
Yes, not 0, but for convenience, I'll say 0.
$hint = ""; is defined outside of the for loop; when $i = 0, $hint is empty and the string is entered into the if ($hint = = "") judgment but the loop plus 1 o'clock is $i = 1 o'clock at this time the $hint is no longer an empty string; This judgment is to distinguish the first cycle
$hint = ""; is defined outside of the for loop; when $i = 0, $hint is empty and the string is entered into the if ($hint = = "") judgment but the loop plus 1 o'clock is $i = 1 o'clock at this time the $hint is no longer an empty string; This judgment is to distinguish the first cycle
Actually, you don't have to judge.
This is used to determine whether the first line, not the first line, is preceded by
Line break
In fact, the list of such things, give CSS to do better, do not add
, it is also omitted to judge.