Jump to content


Photo

PHP, XHTML strict and special characters


  • Please log in to reply
1 reply to this topic

#1 semtex

semtex
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 20 May 2006 - 08:23 PM

I'm using the xhtml strict doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 


As I'm making a database driven website with PHP and MySQL, there's often special characters appearing in my XHTML that are not validating. I'm thinking of a character like "&" (should be "&amp;")

What's the best way to solve this? I mean I can't use php's htmlentities() function on every echoed text, can I?

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 20 May 2006 - 08:46 PM

[!--quoteo(post=375563:date=May 20 2006, 09:23 PM:name=semtex)--][div class=\'quotetop\']QUOTE(semtex @ May 20 2006, 09:23 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]What's the best way to solve this? I mean I can't use php's htmlentities() function on every echoed text, can I?[/quote]
You can, although what I do is just type the entities instead of the actual character - Just a matter of habit now...
<?php
echo "I really fancy some tea &amp; crumpets!";
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users