Re: help in understanding string / integer concatenation
| From: | Michael Purdy | Date: | Wed, 12 Jan 2005 08:04:48 +0000 |
| Subject: | Re: help in understanding string / integer concatenation | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-25290@lists.php.net to get a copy of this message | ||
Raymond
This produces what I think you want:
$str = 'hello' . ($i+1);
Mike
----- Original Message -----
From: "Raymond Still" <rstill@canada.com>
To: <php-windows@lists.php.net>
Sent: Wednesday, January 12, 2005 4:50 PM
Subject: [PHP-WIN] help in understanding string / integer concatenation
> Hello all;
> I am a new PHP user. (But not new at programing.) I'm
> running Win XP, Apache, PHP 5.0.3 (and PostgreSQL 8,
> not that that should make a difference).
>
> I'm trying to use PHP to generate drop down lists of
> arbitrary length in a form (<select> and <option>)
>
> I've come across something strange, to me, in using the
> concatenation (.) operator. A simplified piece of code
> follows. My question is, why is the output different
> between the two versions?
> apologies if I've missed something in the list archives.
> Thanks in advance.
> Ray
>
> <html>
> <head>
> <title>Untitled</title>
> </head>
> <body>
> <?PHP
> $i=4;
> $str = 'hello "' . $i+1 . '"';
> echo $str;
>
> ?>
> </body>
> </html>
>
>
> output:
> --------------------
>
> 1"
>
>
> or, version 2, same as above except break
>
> $str = 'hello "' . $i+1 . '"';
>
> into
>
>
> $str = 'hello "';
> $str .= $i+1 . '"';
>
> output becomes:
> --------------------
> hello "5" (this is what I want to see)
>
> IE vs. netscape makes no difference.
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>