0

I'm validating my web pages with W3C's validator, and it gives me the following error when I try to use GET variables in my hyperlinks:

& did not start a character reference. (& probably should have been escaped as &.)

I'm using the standard format:

... href='url.php?var1=val1&var2=val2' ...

It's throwing this error numerous times with links from my affiliate programs, as well. Should I just ignore this?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Adam11
  • 493
  • 3
  • 12

2 Answers2

0

You should encode the ampersands as they have special meaning in HTML:

... href='url.php?var1=val1&var2=val2' ...

In general browsers cope pretty well with unencoded ampersands, but it's good practise to encode them.

Mark Parnell
  • 9,175
  • 9
  • 31
  • 36
0

& should be &. You can entity escape your strings by passing them to htmlspecialchars()

... href="<?php echo htmlspecialchars( 'url.php?var1=val1&var2=val2', ENT_QUOTES ); ?>" ...