As a matter of fact, going into and out of HTML blocks generates pretty much the same intermediate code as echo does - echo is built into the language at the very same level. If you use printf() or something like that, though, you'll feel a significant difference.
That wasn't the case in PHP 3.0 (as far as I recall anyway, it's been a while). Zeev On Sun, 28 Oct 2001, Brian Moon wrote: > It has always been my understanding that in/out is faster as PHP does not > have to evalutate the terms for variables. The best test would be to use an > app like apache bench (aka: ab) against the two pages. Like this: > > Test 1 > ------- > <?php > > $var=array(1,2,3,4,5); > for($x=0;$x<100;$x++){ > echo "Hello"; > } > $var2=array(6,7,8,9,10); > > ?> > > > results: > --------- > This is ApacheBench, Version 1.3c <$Revision: 1.45 $> apache-1.3 > Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ > Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/ > > Server Software: Apache/1.3.20 > Server Hostname: phorum.org > Server Port: 80 > > Document Path: /~brian/test.php > Document Length: 500 bytes > > Concurrency Level: 3 > Time taken for tests: 0.523 seconds > Complete requests: 100 > Failed requests: 0 > Total transferred: 67830 bytes > HTML transferred: 51000 bytes > Requests per second: 191.20 > Transfer rate: 129.69 kb/s received > > Connnection Times (ms) > min avg max > Connect: 1 4 8 > Processing: 12 9 7 > Total: 13 13 15 > > > Test 2 > ------- > <?php > $var=array(1,2,3,4,5); > for($x=0;$x<100;$x++){ > ?>Hello<?php > } > $var2=array(6,7,8,9,10); > ?> > > > results: > --------- > This is ApacheBench, Version 1.3c <$Revision: 1.45 $> apache-1.3 > Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ > Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/ > > Server Software: Apache/1.3.20 > Server Hostname: phorum.org > Server Port: 80 > > Document Path: /~brian/test1.php > Document Length: 500 bytes > > Concurrency Level: 3 > Time taken for tests: 0.515 seconds > Complete requests: 100 > Failed requests: 0 > Total transferred: 67830 bytes > HTML transferred: 51000 bytes > Requests per second: 194.17 > Transfer rate: 131.71 kb/s received > > Connnection Times (ms) > min avg max > Connect: 1 4 8 > Processing: 11 9 7 > Total: 12 13 15 > > ------------------------------------------- > > So, as you can see, there is a difference but not that much. Perhaps if you > were echoing an entire page it would make a large difference. You should > read Nathan Wallace's paper "PHP: Hackers Paradise Revisited" > http://www.e-gineer.com/articles/php-hackers-paradise-revisited.phtml. In > it he talks about speed of coding and not speed of code. Take it with a > grain of salt but it is true. Sometimes it is more important how long it > takes to code something than it is how fast it runs. PHP makes it easy to > code fast while making sure the code runs fast enough. > > Brian. > > ----- Original Message ----- > From: "Andre Nęss" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Sunday, October 28, 2001 6:11 PM > Subject: [PHP-DEV] Echo vs in/out > > > I'm currently in the middle of a discussion with some fellow PHP > developers regarding the speed of what we call in/out compared to > echo. With in/out we mean stuff like this: > > // php code > ?> > <html>some html</html> > <?php > // more php > > The manual states that PHP treats ?><?php as an echo statement, and I > don't think there can be any speed difference between the two, however one > of my fellow developers thinks there is a difference, and created a test > which showed a 60% speed difference (using a for loop that ran 10000 > times). The test was badly executed IMO, so I ran my own which showed > virtually no difference, but rather than getting into a flame-war I > thought I'd just ask here for a quick answer. Is there a difference, and > if so, is it significant? > > Regards > André Nęss > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > -- Zeev Suraski <[EMAIL PROTECTED]> http://www.zend.com/ -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]