Re: Which is more expensive: concatenation or embedding?
| From: | Gyozo Papp | Date: | Sat, 23 Jun 2001 13:15:38 +0000 |
| Subject: | Re: Which is more expensive: concatenation or embedding? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-54975@lists.php.net to get a copy of this message | ||
Hello,
and for those who came from the realm of C:
printf('This is a string and my variable $x is %s',$x);
I've made a little test with the mentioned three methods and the difference is less than minor.
Choose what you can read and understand easier.
----- Original Message -----
From: "Jason Lustig" <lustig@acsu.buffalo.edu>
To: "Php-General@Lists. Php. Net" <php-general@lists.php.net>
Sent: 2001. június 22. 23:04
Subject: [PHP] Which is more expensive: concatenation or embedding?
> 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
>