RE: [PHP] String concatenation
| From: | Jason | Date: | Fri, 30 Jun 2000 20:28:30 +0000 |
| Subject: | RE: [PHP] String concatenation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4133@lists.php.net to get a copy of this message | ||
I try to stick with whatever is easier to read. The dot operator is really
nice when you're doing stuff like this:
$var1 = "I like PHP";
$var1 .= " and that's enough for me!";
Jason
> -----Original Message-----
> From: Data Driven Design [mailto:jeff@datadrivendesign.com]
> Sent: Friday, June 30, 2000 1:56 PM
> To: php@theOrb.net; php-general@lists.php.net
> Subject: Re: [PHP] String concatenation
>
>
> 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
> >
>
>
> --
> 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
>
>
_______________________________________________________
Site Design, Hosting, and E-Commerce at www.webpipe.net