Hi,
can anyone tell me what does the ".=" operator do? or probably how does it work..?
$themelist .= "$file ";
thx[/quote]
the .= operator
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
.= means add it to a varible
Code: Select all
<?
$variable .= 'hello ';
$variable .= 'Johnny';
echo $varable;
//outputs Hello Johnny
?>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
the . is a concatenation operator:
the = is an asignment operator:
when combining them together it is like saying
$text = $text . $num ::
there are also others like
+=
-=
/=
*=
++
--
Code: Select all
$num = 1;
$text = "Number: " . $num;
echo $text;
//will output: Number: 1Code: Select all
$text = "Number 1";
echo $text;
//will output Number 1$text = $text . $num ::
Code: Select all
$text = "Number ";
$num = 1;
$text .= $num; //same as $text = $text . $num
//will output Number 1+=
-=
/=
*=
++
--
Last edited by Illusionist on Wed Apr 07, 2004 9:47 pm, edited 1 time in total.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
i left out a few on my other assignment operators above, here is a more coimplete list from here:
Code: Select all
See the Arithmetic Operators page (http://www.php.net/manual/en/language.operators.arithmetic.php)
Assignment Same as:
$a += $b $a = $a + $b Addition
$a -= $b $a = $a - $b Subtraction
$a *= $b $a = $a * $b Multiplication
$a /= $b $a = $a / $b Division
$a %= $b $a = $a % $b Modulus
See the String Operators page(http://www.php.net/manual/en/language.operators.string.php)
$a .= $b $a = $a . $b Concatenate
See the Bitwise Operators page (http://www.php.net/manual/en/language.operators.bitwise.php)
$a &= $b $a = $a & $b Bitwise And
$a |= $b $a = $a | $b Bitwise Or
$a ^= $b $a = $a ^ $b Bitwise Xor
$a <<= $b $a = $a << $b Left shift
$a >>= $b $a = $a >> $b Right shift