Re: Which way is better?
| From: | Greg Donald | Date: | Fri, 09 May 2003 01:33:42 +0000 |
| Subject: | Re: Which way is better? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146955@lists.php.net to get a copy of this message | ||
> For me, I attempt to stay in PHP whenever possible, but sometimes it makes
> more sense to go back to html, like a 20 line table, or something with lots
> of quotes which in turn need escaping, which in turn make things unreadable,
> eg:
>
> <?
> if($foo) {
> echo "<a href=\"javascript('foo({$somevar}')\"
> target=\"_blank\">Click
> \"here\"</a>";
> }
> ?>
I'd use heredoc syntax:
<?php
$var = true;
$html = <<<EOF
<a href="link.php?var=$var">Click here</a>
EOF;
echo $html;
?>
No escaping any quotes and you can toss variables in there as well.
--
Greg Donald
http://destiney.com/