Re: echo string conatining ; or "
| From: | Matt McClanahan | Date: | Tue, 31 Oct 2000 08:01:52 +0000 |
| Subject: | Re: echo string conatining ; or " | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22872@lists.php.net to get a copy of this message | ||
On Tue, 31 Oct 2000, Boris.C wrote:
> I tried to fond a way echoing "s and ;s, but I found nothing like escape()
> in Java Script. Can you tell me how to echo
> <input name="f1" value="Hello Sweet World"> ?
The simplist way to do it would be
echo "<input name=\"f1\" value=\"Hello Sweet World\">";
I find this visually unpleasant, so I tend to using single quotes, and
concatenate the string if it includes variables.
echo '<input name="f1" value="' . $fieldvalue . '">
But, if you're outputting a block of html, it can improve code readability
to do it outside of PHP. For example,
for ($i = 0; $i < 5; $i++)
{
?>
Field <?= $i ?>:<br>
<input type="text" name="field<?= $i ?>">
<input type="checkbox" name="boxes[]"> Active
<hr size="1" width="60%" align="left" noshade>
<?
}
HTH,
Matt