Re: String concatenation

From: Date: Fri, 30 Jun 2000 19:55:54 +0000
Subject: Re: String concatenation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4130@lists.php.net to get a copy of this message
I usually use the dot operator when I'm putting a function into a string. print "You ordered $quantity widgets for $" . number_format($price,2) . " each\n"; Data Driven Design P.O. Box 1084 Holly Hill, FL 32125-1084 Phone : (904) - 226-8979 URL : http://www.datadrivendesign.com URL : http://www.rossidesigns.net ----- Original Message ----- From: <php@theOrb.net> To: <php-general@lists.php.net> Sent: Friday, June 30, 2000 9:07 AM Subject: [PHP] String concatenation > 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. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#4130) next »