Title: Variable Concatenation
Contributor: Randall Goguen (aka Ranman)
Last Update: Tuesday July 18 19:44 EDT 2000
"Concatenation" means joining two into one
Q. What is the diffrence between " and '?
A. By example:
This will print "This is 5 and text."
<?
$var = 5;
$text = "This is $var and text.";
echo $text;
?>
This will print "This is $var and text."
<?
$var = 5;
$text = 'This is $var and text.';
echo $text;
?>
Example 1:
The following prints "Some text then 15.2"
<?
$a = 15.2;
echo $b = "Some text then $a";
?>
Example 2:
The following prints "10.5"
<?
$a = 4.3;
$b = 6.2;
$a += $b;
echo $a;
?>
Example 3:
The following prints "10.5"
<?
$a = 4.3;
$b = 6.2;
$c = $a += $b;
echo $c;
?>
Example 4:
The following prints "11"
<?
$a = 4.3;
$b = 6.2;
$c = 0.5;
$c += $a += $b;
echo $c;
?>
Example 5:
The following prints "10"
<?
$a = 4.3;
$b = 6.2;
$c = -0.5;
$c += $a += $b;
echo $c;
?>
Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999 by LinuxGuruz