NYCPHP Meetup

NYPHP.org

[nycphp-talk] what do you call this? $dollar $dollar.

Hans Zaunere zaunere at yahoo.com
Wed Jun 19 16:12:45 EDT 2002


--- Petr Pomorov <petr at linux.ru> wrote:
> Hi all, what do you call this in English?
> $dollar=1
> $dollar.=2
> $dollar.=3
> Best regards.

Bad programming?

Oh, not to beat a dead horse, but that really should be:

$dollar = '1';
$dollar .= '2';
$dollar .= '3';

where $dollar will now be '123'

Since the concatenating assignment operator
(http://www.php.net/manual/en/language.operators.string.php) is for
strings, and makes no sense with ints.  For ints:

$dollar = 1;
$dollar += 2;
$dollar += 3;

and now $dollar is 6 by way of the combined operators.
http://www.php.net/manual/en/language.operators.assignment.php

Also note the important distinction about references in the last
paragraph (as noted in my references presentation, when using .= made
PHP loop endlessly).

HZ




__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the talk mailing list