RE: [PHP] Is there an alternative to double quotes?
| From: | Jaime Bozza | Date: | Wed, 23 Oct 2002 14:45:43 +0000 |
| Subject: | RE: [PHP] Is there an alternative to double quotes? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-121107@lists.php.net to get a copy of this message | ||
Try this:
<?php
print <<<EOT
...
<input type="hidden" name="fname" value="$fname">
<input type="hidden" name="mname" value="$mname">
...
EOT;
?>
The only thing that may cause a problem is putting a $ into your text.
If you change it to \$ it should print fine.
Also, if you want to use an array variable or something more complex,
you should put {} around the variable definition. For instance:
<?php
print <<<EOT
...
<input type="hidden" name="fname"
value="{$fields["fname"]}">
...
EOT;
?>
You don't need to use print either. You can assign the data to a
variable just as easily.
<?php
$text = <<<EOT
...
<input type="hidden" name="fname"
value="{$fields["fname"]}">
...
EOT;
?>
Just make sure there isn't any whitespace after the <<<EOT
Experiment and have fun!
Jaime Bozza