Which is more expensive: concatenation or embedding?

From: Date: Fri, 22 Jun 2001 21:04:45 +0000
Subject: Which is more expensive: concatenation or embedding?
Groups: php.general 
Request: Send a blank email to php-general+get-54931@lists.php.net to get a copy of this message
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

« previous php.general (#54931) next »