operafanboy Posted March 18, 2006 Share Posted March 18, 2006 If so what would be an example? I'm just curious.Cheers Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/ Share on other sites More sharing options...
v-wdd Posted March 18, 2006 Share Posted March 18, 2006 You mean using "&" instead of "&"...If yes, then it is necessary, for XHTML validation. Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-18612 Share on other sites More sharing options...
operafanboy Posted March 19, 2006 Author Share Posted March 19, 2006 [!--quoteo(post=356209:date=Mar 18 2006, 01:29 PM:name=vic-wdd)--][div class=\'quotetop\']QUOTE(vic-wdd @ Mar 18 2006, 01:29 PM) [snapback]356209[/snapback][/div][div class=\'quotemain\'][!--quotec--]You mean using "&" instead of "&"...If yes, then it is necessary, for XHTML validation.[/quote]Yeah, thanks. Is there any point to it though? I don't think I've ever needed to use it, and can't think of any time it would be needed, and it's pretty annoying having to remember to do it just so your page is valid. Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-18729 Share on other sites More sharing options...
azziman Posted March 20, 2006 Share Posted March 20, 2006 [!--quoteo(post=356333:date=Mar 19 2006, 04:04 AM:name=operafanboy)--][div class=\'quotetop\']QUOTE(operafanboy @ Mar 19 2006, 04:04 AM) [snapback]356333[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yeah, thanks. Is there any point to it though? I don't think I've ever needed to use it, and can't think of any time it would be needed, and it's pretty annoying having to remember to do it just so your page is valid.[/quote]well if u type your text into dreamweaver (or u just copy it in) the "&" code will be there for u ;) Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-19037 Share on other sites More sharing options...
rawb Posted March 21, 2006 Share Posted March 21, 2006 I'm not sure if this is what you mean, but the ampersand is used to begin "special characters" in HTML. For example - if you ever need to know how to display a copyright ©, the HTML code is & #169; - but without the space in between the ampersand and the pound sign.If this isn't what you mean, I'm dumb - sorry. If it is, hope I helped a bit! Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-19321 Share on other sites More sharing options...
Gast Posted March 23, 2006 Share Posted March 23, 2006 Like vic-wdd said, you need to use & in the code instead of & for it to be valid XHTML. Also, if you are writing in JavaScript that directs to a URL like "http://www.example.com/page.php?act=test&something=this", for example you cannot use the & in the JS code, it won't work, so you must use a normal ampersand even if it won't validate. Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-19896 Share on other sites More sharing options...
gnuffo1 Posted March 24, 2006 Share Posted March 24, 2006 I don't know if & works in JS, but &038; definitly does and my page validates with it. Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-20414 Share on other sites More sharing options...
charlesfw Posted April 16, 2006 Share Posted April 16, 2006 [!--quoteo(post=356209:date=Mar 18 2006, 02:29 PM:name=vic-wdd)--][div class=\'quotetop\']QUOTE(vic-wdd @ Mar 18 2006, 02:29 PM) [snapback]356209[/snapback][/div][div class=\'quotemain\'][!--quotec--]You mean using "&" instead of "&"...If yes, then it is necessary, for XHTML validation.[/quote]I have a twist on this question. I have images stored in the database and to print them as a link, I must send all information relative to the <img> tag as an argument.I don't want to distract from the issue, but this is the code that prepares the link to see a full-sized image from a thumbnail: // Build full-size image link $image_link = "print_full_image.php?"; $image_link .= "id=".$id; $title = ereg_replace(" ", "%20", $title); $image_link .= "&title=".$title; $image_link .= "&seq=".$row->sequence; $caption = ereg_replace(" ", "%20", $row->caption); $image_link .= "&caption=".$caption; $image_link .= "&table=$db_table"; // Build thumbnail image request $image = "print_image.php?"; $image .= "id=".$id; $image .= "&seq=".$row->sequence; $image .= "&thumbnail=Y"; $image .= "&table=$db_table"; // Print link & image print "<td><a href=".$image_link."><img src=".$image. " alt=\"Click to see larger view\"/></a></td>";It replace spaces with '%20' which appears to be what the browser (IE) does automatically. I don't know of any HTML or PHP method to do this automatically so I am building this string manually.The issue is that if $caption contains an ampersand, it causes the rest of the text to be truncated. So it appears that '&' is illegal in this case since it is always interpreted as a separator.Am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/5219-is-it-ever-necessary-to-use-the-ampersand-escape-character-for-html/#findComment-27577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.