help in understanding string / integer concatenation
| From: | Raymond Still | Date: | Wed, 12 Jan 2005 06:50:45 +0000 |
| Subject: | help in understanding string / integer concatenation | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-25288@lists.php.net to get a copy of this message | ||
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.