![]() |
|
#11
|
|||
|
|||
|
Syedur is on a PHP server, Abhi.
Try this: [code:zcy2uwiiyz] <?php // begin of page function validXHTML($buffer){ $buffer = str_replace("&", "&", $buffer); $buffer = str_replace("\"", ""e;", $buffer); return $buffer; } ob_start("validXHTML"); ?> [/code:zcy2uwiiyz] The output of the page goes through validXHTML(), where & and " are replaced. Then the buffer is returned and send to the client. Disclaimer: I haven't tested this.. but I'm pretty confident it'll work ![]() - [url="http://neo.dzygn.com/"]Mark[/url:zcy2uwiiyz] |
|
#12
|
|||
|
|||
|
hehe, yea I know (serverside). I misunderstood his or anyone else to an example.
![]() |
|
#13
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">Originally posted by Mark
Syedur is on a PHP server, Abhi. Try this: [code:gxieilumm6] <?php // begin of page function validXHTML($buffer){ $buffer = str_replace("&", "&", $buffer); $buffer = str_replace("\"", ""e;", $buffer); return $buffer; } ob_start("validXHTML"); ?> [/code:gxieilumm6] The output of the page goes through validXHTML(), where & and " are replaced. Then the buffer is returned and send to the client. Disclaimer: I haven't tested this.. but I'm pretty confident it'll work ![]() - [url="http://neo.dzygn.com/"]Mark[/url:gxieilumm6] <hr id="quote"></blockquote id="quote"></span id="quote"> Parse Error on line 4... which is "return $buffer;" |
|
#14
|
|||
|
|||
|
Odd, it works fine on my system.
By the way, the forum software interpreted one part of the code wrong, I've updated my post now. - [url="http://neo.dzygn.com/"]Mark[/url:6mh4nc16vy] |
|
#15
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">$buffer = str_replace("\"", ""e;", $buffer);<hr id="quote"></blockquote id="quote"></span id="quote">
Actually, " (quotation mark) does't have to be written as " (not "e , if it's not in an attribute value of course.You didn't include < though Mark, so the code should probably look something like this (kept the "): [code:58etbbgoe4] <?php // begin of page function validXHTML($buffer){ $buffer = str_replace("&", "&", $buffer); $buffer = str_replace("\"", """, $buffer); $buffer = str_replace("<", "<", $buffer); return $buffer; } ob_start("validXHTML"); ?> [/code:58etbbgoe4] <font face="Courier New">-- David</font id="Courier New"> |
|
#16
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">How would that help? If I understand Syedur right, he's having problems with '&' and '<' which has to be encoded as e.g. & and < repectively. But this has to be done in HTML too.<hr id="quote"></blockquote id="quote"></span id="quote">
No. http://validator.w3.org/check?uri=ht...om%2Ftest.aspx Sorry but HTML is fine for your needs, gratuitous abuse of XHTML is nothing more than a waste of your time. Unless of course, you like wasting your time. <blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote"> function validXHTML($buffer){ $buffer = str_replace("&", "&", $buffer); $buffer = str_replace("\"", """, $buffer); $buffer = str_replace("<", "<", $buffer); return $buffer; } ob_start("validXHTML"); <hr id="quote"></blockquote id="quote"></span id="quote"> Do you really want to shag the performance and cachability of your page with code like that? -- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#17
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">No.<hr id="quote"></blockquote id="quote"></span id="quote">
Well, they don't have to be escaped always, but '<' and '&' have special meaning in HTML (and you know for what). Try something like [code:9buqeh3fnx] x&y a<b [/code:9buqeh3fnx] <blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">Do you really want to shag the performance and cachability of your page with code like that?<hr id="quote"></blockquote id="quote"></span id="quote"> Blame it on Mark , I only modified his code.<font face="Courier New">-- David</font id="Courier New"> |
|
#18
|
|||
|
|||
|
Well I don't have an axe to grind man, but so many people abuse XHTML (like Flash heh).
-- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#19
|
|||
|
|||
|
what is abuse of XHTML to you?
What do you think the purpose of it? How do you think people misuse it? |
|
#20
|
|||
|
|||
|
<blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote">
But, what if the content is dynamic and it is being generated via something else; server side and such. what do I do then? <hr id="quote"></blockquote id="quote"></span id="quote"> Is it hard to generate directly escaped data? <blockquote id="quote"><span class="smalltext" id="quote">quote:<hr id="quote"> No. http://validator.w3.org/check?uri=ht...om%2Ftest.aspx <hr id="quote"></blockquote id="quote"></span id="quote"> David is right, Tim. You can do the same in xhtml and get only a *very* tiny warning: [code:ky8eomwq3k] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> </head> <body> <div> x & y a < b </div> </body> </html> [/code:ky8eomwq3k] as far as you dont write: [code:ky8eomwq3k] x&y a<b [/code:ky8eomwq3k] funny stuff.. -- Chris |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|