0

Once again, I have no choice but to ask you guys for help on this one as i'm completely baffled and I've been trying to solve it this past hour.

I have some php code structured something like this :

function build($url=""){
    $output = '<ul class= "bc-ul">'; 
    $output .= '<li class= "bc-li"><a class="bc" href=" complex concatenation of link here">link1</a></li>';
    $output .= '<li class= "bc-li"><a class= "bc">link2</a></li>';
    $output .= '<li class= "bc-li"><a class= "bc">link3</a></li>';
    $output .= '</ul>';

return $output; 
}

All anchors href's have a complex concatenated url.. The problem is that when $output is displayed using php's echo $output, extra empty anchor tags are generated inside each list. Anyone has an idea what causes this kind of behavior?

Result :

<li>
<a class="bc-li">link1</a>
<a></a>  <- empty tag here
</li>
LogixMaster
  • 586
  • 2
  • 11
  • 36
  • I'm pretty darn sure this is impossible. Are you looking at the resulting *raw HTML* or are you looking at it in the DOM inspector? Big difference! – deceze Nov 26 '13 at 11:39
  • 4
    are you viewing the page source to see this, or your browsers inspector? If it's the latter, then it's most likely your HTML markup isn't correct so your browser will try and 'fix' it. So, my educated, blind stab in the dark: your 'complex' url contains a `"`. – Prisoner Nov 26 '13 at 11:39
  • Man! That's some problem! Could you give me a real example of one of your concatenated URLs? – sheng Nov 26 '13 at 11:39
  • @ShengSlogar sure : href = "index.php?dir='.rawurlencode($link_string).'\\'.rawurlencode($value).'">' – LogixMaster Nov 26 '13 at 11:45
  • @deceze I thought the same thing at first, but the thing is that this empty anchor tag is being styled the same as its sibling.. but it has no class and its empty. – LogixMaster Nov 26 '13 at 11:46
  • There's your problem! You have a close anchor and li tag! Take this out! You are already adding these in build(). – sheng Nov 26 '13 at 11:47
  • @Prisoner I've checked my markup and all tags are opened and closed as they should be – LogixMaster Nov 26 '13 at 11:47
  • @ShengSlogar no sorry my bad, href value is "index.php?dir='.rawurlencode($link_string).'\\'.rawurlencode($value)" – LogixMaster Nov 26 '13 at 11:51
  • Oops... instead of giving me rawurlencode($var) you could give me an after-script URL? – sheng Nov 26 '13 at 11:54
  • @ShengSlogar sure can : Documents dont mind the class names.. – LogixMaster Nov 26 '13 at 11:56
  • Ahh... I'm as lost as you are. That href looks perfectly correct. Check your HTML with view source in your web browser. – sheng Nov 26 '13 at 11:57
  • Again, is what you're showing us the *raw output* or are you getting that from the browser's Web Inspector/DOM Inspector/Firebug? – deceze Nov 26 '13 at 12:00
  • @deceze It's the raw output from page source.. – LogixMaster Nov 26 '13 at 12:06
  • Please provide a *complete self contained example.* Some piece of code we can run to verify exactly this phenomenon. – deceze Nov 26 '13 at 12:21

0 Answers0