Re: help in understanding string / integer concatenation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Raymond

This produces what I think you want:

$str = 'hello' . ($i+1);

Mike


----- Original Message ----- 
From: "Raymond Still" <rstill@xxxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Wednesday, January 12, 2005 4:50 PM
Subject:  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
> 

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux