- From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- Date: Thu, 23 Jul 2009 10:17:37 +0200
- To: Leif Halvard Silli <lhs@malform.no>
- Cc: HTML WG <public-html@w3.org>
Leif Halvard Silli wrote:
> Anne van Kesteren On 09-07-22 12.53:
>> and also does not work in common PHP scenarios
>> such as
>>
>> <div<?php if($foo) { echo " class='bar'"; }?>>
>
> But since we are talking HTML and not XHTML, you could use
>
> <div class=' <?php if($foo) { echo " bar"; }?>' >
>
> and be valid.
That doesn't work for boolean attributes, where you have to do this:
<input type="checkbox"<?php echo $disabled ? ' disabled' : ""; ?>>
The only way to achieve the same result, while still technically being
well-formed XML or SGML is to do this:
<?php if ($disabled) { ?>
<input type="checkbox" disabled="disabled" />
<?php } else { ?>
<input type="checkbox" />
<?php } ?>
But that doesn't really scale well when you have multiple attributes,
each requiring their own if statement.
--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/
Received on Thursday, 23 July 2009 08:18:17 UTC