变量不与 ' 或 " 或 \" 相呼应
Variable not echoing with ' or " or \"
第 1 行与食品品牌的内容相呼应时遇到了一些麻烦...
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value=\"$brand\"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
更新
$hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.musicDetailTitle4.value="'.$artist.'"; document.contactForm.musicDetailArtist4.value=4;">fill form'.$artist."-".$title."-".$id."</a>";
这是因为变量没有用单引号解析:
..."javascript:document.contactForm.itemDetailTitle4.value="'. $brand .'"; document...
像上面一样使用串联。
变量仅在引用标记之间解析
echo 'Text $var'; //apostrophe will not parse variable
echo "Text $var"; //citation marks will parse
在你的情况下,你应该这样做,这样你就不必与之抗争:
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="' . $brand . '"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
- 首先
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
第二个
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="'.$brand.'"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'
第 1 行与食品品牌的内容相呼应时遇到了一些麻烦...
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value=\"$brand\"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
更新
$hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.musicDetailTitle4.value="'.$artist.'"; document.contactForm.musicDetailArtist4.value=4;">fill form'.$artist."-".$title."-".$id."</a>";
这是因为变量没有用单引号解析:
..."javascript:document.contactForm.itemDetailTitle4.value="'. $brand .'"; document...
像上面一样使用串联。
变量仅在引用标记之间解析
echo 'Text $var'; //apostrophe will not parse variable
echo "Text $var"; //citation marks will parse
在你的情况下,你应该这样做,这样你就不必与之抗争:
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="' . $brand . '"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
- 首先
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
第二个
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="'.$brand.'"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'