Re: Re: HTML errors
| From: | David McGlone | Date: | Wed, 12 Jan 2011 11:32:28 +0000 |
| Subject: | Re: Re: HTML errors | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310691@lists.php.net to get a copy of this message | ||
On Wednesday, January 12, 2011 04:14:42 am Pete Ford wrote:
> On 12/01/11 03:35, David McGlone wrote:
> > Hi Everyone, I'm having a problem validating some links I have in a
> > foreach.
> >
> > Here is my code:
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> >
> > "http://www.w3.org/TR/html4/loose.dtd">
> >
> > my PHP code:
> > $categorys = array('home', 'services', 'gallery',
> > 'about_us',
> > 'contact_us', 'testimonials');
> > foreach($categorys as $category){
> > $replace = str_replace("_", " ", $category);
> > echo "<li><a
> > href='index.php?page=$category'>$replace</a></li>";
> > }
> >
> > Validator Error:
> > an attribute value must be a literal unless it contains only name
> > characters
> >
> > …ome>home</a></li><li><a
> > href=index.php?page=services>services</a></li><li><a h…
> >
> > I have tried various combinatons and different doctypes. I'm beginning to
> > wonder if this code is allowed at all.
>
> All the other replies are talking nonsense (especially Daniel ;) !
> There's no reason why HTML with single-quoted attributes isn't valid, so in
> principle your expected output of
>
> <a href='index.php?page=services'>services</a>
>
> should be OK.
>
> The real challenge is to understand why the code fragment you have
> presented is losing the single quotes: are you *sure* this is exactly what
> you have in your file (i.e. have you copied it to the posted message
> properly) ?
Thanks Pete. Funny story. Ya'll better not laugh, especially you Denial, oops
I mean Daniel ;-)
Anyway, All of us would never have fixed this error. We could have added double
quotes, single quotes and every combination even the worlds best programmer
would use and it wouldn't have gotten us anywhere. Thats because if your
working on the wrong file......... :-)
--
Blessings
David M.