[thelist] quoting attributes was not filling total width
Joe Crawford
jcrawford at avencom.com
Tue Apr 17 13:00:49 CDT 2001
Tony Crockford wrote:
> Aardvark said:
> >btw, you really should get into the habit of quoting attributes...
>
> As a PHP newbie, I found that errors are reported when I use quotes on
> attributes. Am I missing something?
>
> What's the *right* way?
>
> Upper case tags, quoted attributes.
>
> Lower case tags, quoted attributes.
>
> Lower case tags, unquoted attributes.
>
> Right for now? Right for future?
PHP has to live with HTML in the same files, this is complicated, kind
of.
For html, case does not matter. I used to like <UPPERCASE TAGS="really">
for readability, but the XHTML spec is in line with XML, and actually
*requires* lowercase <tags> and attributes, with all attribute values
quoted.
Now for PHP, quotes get complicated - because:
<?php
// these two lines do different things
$world="world";
echo "hello $world";
echo 'hello $world';
?>
And if you add html coding to the mix it gets really complicated:
<?php
// this will break
$world="world";
echo "<p align="center">hello $world</p>";
?>
To use double quotes you'd have to (all the fun of HTML in perl!) escape
them:
<?php
// this will work, but you have to escape the quotes
$world="world";
echo "<p align=\"center\">hello world</p>";
?>
The lazy among us who don't want to turn:
echo "<a href="$url" title="$urltitle">$urltext</a>";
into:
echo "<a href=\"$url\" title=\"$urltitle\">$urltext</a>";
Do something like this:
<a
href="<?php echo $url; ?>"
title="<php echo $urltitle; ?>"
><?php echo $urltext; ?></a>
Just for readability.
...
http://www.artlung.com/lab/php/gallery/ is another example of that
coding style.
HTH,
Joe <http://artlung.com/>
--
Joe Crawford |||||||||||||| mailto:jcrawford at avencom.com
|||||||||||||||||||||||| http://www.avencom.com
||||||||||||||||||||||||||| Avencom: Set Your Sites Higher
More information about the thelist
mailing list