RE: [PHP] $string . "text" not working properly
| From: | Krznaric Michael | Date: | Mon, 13 Nov 2000 16:53:21 +0000 |
| Subject: | RE: [PHP] $string . "text" not working properly | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24978@lists.php.net to get a copy of this message | ||
You should try
$MESSAGE .= $IMAGE . "Only $" . ($AMOUNT - $USED) . " available.<br>\n";
Didn't try it, but I suspect it should work.
Mike
-----Original Message-----
From: Brian T. Allen [mailto:brian@gzmarketing.com]
Sent: Monday, November 13, 2000 11:49 AM
To: Php
Subject: [PHP] $string . "text" not working properly
Hi *,
Consider the following code, which I think should work:
<?
$IMAGE = "<img src=\"/images/error.gif\">";
$MESSAGE = "Message:<br>\n";
$AMOUNT = "10";
$USED = "6";
$MESSAGE .= $IMAGE . "Only $" . $AMOUNT - $USED . " available.<br>\n";
echo $MESSAGE;
?>
This should output:
Message:<br>
<img src=\"/images/error.gif\">Only $4 available.<br>
But instead it outputs:
Message:<br>
-6 available.<br>
Notice that it drops the $IMAGE and "Only $", not to mention calculating the
math incorrectly (actually, it drops $AMOUNT resulting in an accurate but
unwanted "0 - 6" calculation.
I have long suspected problems with the $VAR = $START . " hello world " .
$END; syntax, but this is the first easily reproducible instance of it.
I have used the following as a workaround, but it is of course unacceptable
in the long-run:
$MESSAGE .= $IMAGE;
$MESSAGE .= "Only $";
$MESSAGE .= $AMOUNT - $USED;
$MESSAGE .= " available.<br>\n";
Any thoughts or suggestions?
Brian