Jump to content

& or &, this is question


son
 Share

Recommended Posts

I just validated some web pages and saw the following error:character "&" is the first character of a delimiter but occurred as dataDo I really need to replace & with &? What if user who will be using the character using this also on website? Do I have to worry about this?Thanks,Son

Link to comment
Share on other sites

& is the correct way. If you have user input on your site, it's your business to make sure that the text gets translated to proper HTML. With htmlspecialchars(), for example, if your user input is processed by PHP.

Link to comment
Share on other sites

& is the correct way. If you have user input on your site, it's your business to make sure that the text gets translated to proper HTML. With htmlspecialchars(), for example, if your user input is processed by PHP.
Thanks Ingolme. I suppose this applies to any html element, including meta and title tags? Also, do normal CMS systems that are on the market do the same you think? Just wonder how commercial software might deal with this (I am always keen to learn things in proper way if you know what I mean)...Son
Link to comment
Share on other sites

Yup, this is the proper way to do it for all elements. Most CMS systems probably use a function to encode the characters in displayed data: maybe PHP's htmlspecialchars(), as Ingolme mentioned.

Edited by Fmdpa
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...