String concatenation
| From: | php at theOrb dot net | Date: | Fri, 30 Jun 2000 13:07:01 +0000 |
| Subject: | String concatenation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4013@lists.php.net to get a copy of this message | ||
Hi all,
I've noticed that all of the documentation uses the dot (".") operator
to concatenate strings; however, I've also noticed that the PHP parser
will expand variables within a string.
Is there any compelling reason to use one method over the other? (For
clarity and the fewer typos I'd make I prefer the latter)
<?
$word1 = "rock";
$word2 = "roll";
$string1 = "I like " . $word1 . " and " . $word2 ".<br>\n";
$string2 = "I like $word1 and $word2.<br>\n";
if ($string1 == $string2)
$answer = "identical";
else
$answer = "different";
echo "The two strings are $answer<br>\n";
?>
Maybe Rasmus could share his thoughts on this?
Thanx,
Mike Wright
--
Before dot there was dot dot.