Re: Which is more expensive: concatenation or embedding?

From: Date: Fri, 22 Jun 2001 21:39:28 +0000
Subject: Re: Which is more expensive: concatenation or embedding?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54933@lists.php.net to get a copy of this message
What about: echo "This is a string and my variablke $x is ".$x."\n"; I think your first would be faster, but on such a miniscule level as to be irrelevant. -- phill > There are two ways to get your variables into a string -- concatenation with > single-quoted strings, or embedding in evaluated double-quoted strings. > Which is more expensive to the server? > > For example: > > <?php > > $x = 10; > echo "This is a string and my variable \$x is $x.\n"; > echo 'This is a string and my variablke $x is '.$x."\n"; > > ?> > > Now, which is more expensive? Is it more expensive to concatenate them, or > to evaluate the whole string since it would be in double-quotes? I see lots > of people do things in double-quotes, but it would seem to me that > single-quoted strings concatenated with variables would be less expensive > because you are only evaluating the variables. > > --Jason > > > -- > 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 (#54933) next »