Re: Adding to a numeric variable, how?
| From: | Paul Waring | Date: | Sat, 05 Nov 2005 11:22:53 +0000 |
| Subject: | Re: Adding to a numeric variable, how? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225151@lists.php.net to get a copy of this message | ||
On Sat, Nov 05, 2005 at 01:23:01PM +0200, Dotan Cohen wrote:
> How can I shorten it to something like this:
> <?php
> print $number." ".$number+2."\n";
> ?>
Try:
<?php
print $number . ' ' . ($number + 2) . "\n";
?>
I think putting the $number + 2 in brackets will cause PHP to evaluate
that part of the expression before printing it.
Paul
--
Rogue Tory
http://www.roguetory.org.uk