Jump to content

Archived

This topic is now archived and is closed to further replies.

semtex

PHP, XHTML strict and special characters

Recommended Posts

I'm using the xhtml strict doctype:

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


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?

Share this post


Link to post
Share on other sites
[!--quoteo(post=375563:date=May 20 2006, 09:23 PM:name=semtex)--][div class=\'quotetop\']QUOTE(semtex @ May 20 2006, 09:23 PM) [snapback]375563[/snapback][/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...
[code]<?php
echo "I really fancy some tea &amp; crumpets!";
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.