PDA

View Full Version : Simple Question: ( .= )


Ultragames
12-02-2004, 10:53 PM
I've always used .'s like this:$Variable = ("This is " . ($One + $Two) . "!!!");

Does .= Add to the variable? (Not in a place where i can test it out.)

So if $the = 4, would $the .= 6 equal 10?

THanks.

Nightfire
12-03-2004, 12:35 AM
It'll make it 46. All it does is add whatever is in .= to the end of the original string. It doesn't use math or anything

$var = '10';
$var .= '01';
echo $var;

That'll show as 1001

Ultragames
12-03-2004, 06:31 AM
Right right. Thats what i thoguth, but i had a brain fart, and used numbers as an example. so:

$Var = "The";
$Var .= " cat.";

print($Var);
// "The cat."

Thats how it works?

Is there a way to do math without having to use something like this:

$Var = 4;
$Var = ( $Var * 7 );

Brandoe85
12-03-2004, 06:42 AM
This should work

$Var = 4;
$Var *= 7;

marek_mar
12-03-2004, 07:05 AM
For adding:

$may_number=5;
$my_numbr += 4;
print $my_number; // Prints 9.

http://pl.php.net/manual/en/language.operators.assignment.php