Re: Encoding for W3C Validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 3, 2010, at 3:36 PM, Ashley Sheridan wrote:

> On Tue, 2010-08-03 at 15:32 -0400, Rick Dwyer wrote:
>> 
>> On Aug 3, 2010, at 3:15 PM, Sebastian Ewert wrote:
>> 
>> > Ashley Sheridan wrote:
>> >> On Tue, 2010-08-03 at 15:00 -0400, Rick Dwyer wrote:
>> >> 
>> >>> On Aug 3, 2010, at 2:47 PM, Sebastian Ewert wrote:
>> >>> 
>> >>>> Rick Dwyer wrote:
>> >>>>> Hello List.
>> >>>>> 
>> >>>>> In the Alt section of the IMG tag below, the variable $myitem has a value of "Who's There".
>> >>>>> 
>> >>>>> echo "<div class='myclass'><a href='#' class='color_thumb'> <img src='/itemimages/$mypic' alt='$myitem' width='60' ....
>> >>>>> 
>> >>>>> When running through W3C validator, the line errors out because of the " ' " in "Who's".
>> >>>>> I tried:
>> >>>>> $myitem=(htmlentities($myitem));
>> >>>>> 
>> >>>>> But this has no affect on "Who's".
>> >>>>> 
>> >>>>> What's the best way to code this portion so the apostrophe is handled correctly?
>> >>>>> 
>> >>>>> 
>> >>>>> TIA,
>> >>>>> 
>> >>>>> --Rick
>> >>>>> 
>> >>>>> 
>> >>>>> 
>> >>>>> 
>> >>>> Use it
>> >>>> 
>> >>>> 
>> >>>> echo '<div class="myclass"><a href="#" class="color_thumb"> <img
>> >>>> src="/itemimages/'.$mypic.'" alt="'.$myitem.'" width="60" ...'
>> >>> 
>> >>> Thanks Sebastian.
>> >>> 
>> >>> In the above, what is the function of the period in front of $myitem?
>> >>> 
>> >>> --Rick
>> >>> 
>> >>> 
>> >> 
>> >> 
>> >> It is a string concatenation in PHP. But, as my last email on this
>> >> thread shows, you only need to add ENT_QUOTES to your htmlentities()
>> >> call and everything will work.
>> >> 
>> >> Thanks,
>> >> Ash
>> >> http://www.ashleysheridan.co.uk
>> >> 
>> >> 
>> >> 
>> > 
>> > 
>> > If you use single quotes you can't use variables inside the string. You
>> > have to combine strings and variables or two strings with a dot.
>> > 
>> > echo 'foo'.$bar;
>> > 
>> > http://www.php.net/manual/de/language.types.string.php
>> > 
>> > I'm not shure but I think to validate xhtml you need the double quotes.
>> 
>> Problem I'm having is I've inherited a PHP page that contains sections of PHP/Javascript/HTML/CSS all inside of a PHP echo tag.  My PHP and JS skill are rudimentary at best so when it comes to a block of code 40 to 50 lines in length, it becomes daunting to reverse the ' with ".  Each echo block starts with a " and the html inside uses a '.  JS also uses '.
>> 
>> Below is an actual block in more detail with JS in it.  Is it still recommended to switch with " with ' and ' with "?
>> 
>> --Rick
>> 
>> 
>> 	  echo "
>> 	  <p>Click on a picture to view that color:</p>";
>>       If (trim($pic_1) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_1' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_1',0) border='0' /></a></div>";}
>>       If (trim($pic_2) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_2' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_2',0) border='0' /></a></div>";}	    
>>       If (trim($pic_3) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_3' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_3',0) border='0' /></a></div>";}	   
>>       If (trim($pic_4) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_4' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_4',0) border='0' /></a></div>";}	   
>>       If (trim($pic_5) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_5' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_5',0) border='0' /></a></div>";}	  
>>       If (trim($pic_6) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_6' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_6',0) border='0' /></a></div>";}	  
>>       If (trim($pic_7) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_7' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_7',0) border='0' /></a></div>";}	  
>>       If (trim($pic_8) <> "") {echo "<div class='proddetailpics'><a href='#' class='color_thumb'> <img src='/imagedir/$pic_8' alt='$itemgroup $itemsubgroup' width='60' height='60' onclick=MM_swapImage('prodimage','','/imagedir/$pic_8',0) border='0' /></a></div>";}	  
>> 	  }
>> 
>> 
> 
> That's some damn ugly code that I'd consider putting in a loop right away!

The whole page is like this.... that's why I said it was daunting : (

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux