Re: [PHP] Encoding Ampersands

2010-07-29 Thread Shawn McKenzie
On 07/28/2010 11:29 PM, Rick Dwyer wrote: > So htmlentities() will work for "Green, Red & Blue"? > > Will it work for "htm?color=blue&number=2&letter="? > > --Rick For ampersands yes, for other things no. Use the correct tool for the job. To output HTML use htmlentities(). To pass in

Re: [PHP] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
Exactly what I was looking for! Thanks Josh. --Rick On Jul 29, 2010, at 12:33 AM, Josh Kehn wrote: > Rick- > > Give it a try! > > $test_one = "Green, Red & Blue"; > $test_two = "htm?color=blue&number=2&letter=a"; > > echo htmlentities($test_one); // Green, Red & Blue > echo htmlentities($te

Re: [PHP] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
So htmlentities() will work for "Green, Red & Blue"? Will it work for "htm?color=blue&number=2&letter="? --Rick On Jul 29, 2010, at 12:23 AM, Josh Kehn wrote: > Rick- > > Probably would use htmlentities() instead. You could also do str_replace("&", > "&"); > > Regards, > > -Josh

[PHP] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
Hello List. I have variables displaying content from mysql fields. The contents contains & like "Dogs & Cats"... so naturally the W3C validator chokes on them. Is there a way to encode so they display properly on the page but the validator is OK with them? Is the answer as simple as: urlenc