Duff's device
| From: | Hartmut Holzgraefe | Date: | Thu, 14 Dec 2000 19:34:24 +0000 |
| Subject: | Duff's device | ||
| Groups: | php.lang | ||
| Request: | Send a blank email to php-lang+get-99@lists.php.net to get a copy of this message | ||
Just wondering:
as PHP syntax is heavily based on C syntax i was curious if it
would accept this code snippet:
<?php
$to="";
$from="abcdefghijklmnopqrstuvwxyz";
$count=12;
$n = ($count + 7) / 8;
$i=0;
switch ($count % 8)
{
case 0: do { $to .= $from{$i++};
case 7: $to .= $from{$i++};
case 6: $to .= $from{$i++};
case 5: $to .= $from{$i++};
case 4: $to .= $from{$i++};
case 3: $to .= $from{$i++};
case 2: $to .= $from{$i++};
case 1: $to .= $from{$i++};
} while (--$n > 0);
}
echo $to;
?>
sure enugh it didn't although the C equvalent is indead legal
-> http://www.tuxedo.org/~esr/jargon/html/entry/Duff's-device.html
;)
--
Hartmut Holzgraefe hartmut@six.de http://www.six.de
+49-711-99091-77