RE: [PHP] how call a variable in a text
| From: | David Murphy | Date: | Wed, 21 Oct 2009 20:40:00 +0000 |
| Subject: | RE: [PHP] how call a variable in a text | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299168@lists.php.net to get a copy of this message | ||
This is actually much better the { and } make it very obvious where the variable is and also it
can keep odd issues from occurring sometimes.
$message="<b> There is a text {$variable} trial. </b> ";
There is always sprint type functions also.
David
-----Original Message-----
From: Andrew Ballard [mailto:aballard@gmail.com]
Sent: Wednesday, October 21, 2009 3:23 PM
To: Bulend Kolay
Cc: php-general@lists.php.net
Subject: Re: [PHP] how call a variable in a text
2009/10/21 Bulend Kolay <bmalik@ihlas.net.tr>:
> I 'll send a mail in html form using php5.
>
> cat send.php
> <?php
> $variable="date1" ;
> ..
> ..
> $message='
>
> <b> There is a text $variable trial. </b> ';
>
> mail($to, $subject, $message, $headers) ; ?>
>
> when I run send.php, I get the mail. But I can't call variable called
> variable. it comes as string.
> How can I correct this?
>
You need to use double quotes (or HEREDOC) if you want PHP to replace $variable with its value in
the string:
$message="
<b> There is a text $variable trial. </b> ";
or
$message = <<<MESSAGE
<b> There is a text $variable trial. </b> MESSAGE;
Andrew
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php