Already defined hint=0 why also if (hint=0)

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.