Re: HTML errors

From: Date: Wed, 12 Jan 2011 13:20:00 +0000
Subject: Re: HTML errors
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-310693@lists.php.net to get a copy of this message
On Tue, 2011-01-11 at 23:38 -0800, Jim Lucas wrote: > On 1/11/2011 7:35 PM, 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>"; > > Try this instead > > echo '<li><a > href="index.php?page=',$category,'">',$replace,'</a></li>'; > > Jim Lucas [snip] Jim, Not to be a smart ass like Danial was (which was brilliantly written though), but you have your "example" formatted incorrectly. You are using commas instead of periods for concatenation, and it would have thrown an error trying to run your example. :) # corrected: echo "<li><a href=\"index.php?page={$category}\">{$replace}</a></li>"; Steve Staples.

« previous php.general (#310693) next »