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) ?
--
Peter Ford, Developer phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd. www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php