

This means php reads the file from disk and parses it in its entirety.īut yes, outputting strings which are outside of
PHP ECHO HTML CODE CODE
The webserver doesn’t pre parse the file and send the blocks of php code to php. It needs to find its opening and closing tags. Keep in mind, php is parsing every character in the file regardless. The server processor is used no matter whether you echo or whether the html is used outside of browser has to parse it no matter what you do, so that is irrelevant. Save server resources and code correctly I say. So essentially, you’re parsing the same code twice…for no reason whatsoever, and with absolutely no benefit. When it gets to the browser, the browser uses processor usage to render the page. What I find puzzling as well is, if you put HTML within an ECHO, then you’re using processor usage to echo out the HTML. Although there wasn’t much difference in it (1000ms at most), there was a difference, and on a big project it could be wasted processor usage. Now, this isn’t conclusive evidence but, through all of my tests, the code with HTML within PHP ECHO’s took longer to be generated on the server. I did one the way I like to code, and the other with HTML within PHP tags. The script looped 99999 times, and created a drop down item for each loop.

I put some HTML and PHP code between the start and end of the timer.

I wanted to test this for myself, and found a little script which starts a timer, and then ends it. On a small project I doubt you’d see much difference, however on a larger project where there essentially could be thousands of lines of additional code caused by HTML in ECHO’s, it’s going to have a bigger effect. PHP on the server parses everything between the PHP tags, so, the more PHP there is, the more code needs to be parsed, and surely this will have an effect on speed. If you put a table or div with PHP code, it’s really difficult to make changes as you can’t visually see the DIV or tables when you’re in dreamweaver. I like to keep as much HTML as possible as HTML, this way, I can see DIV’s and tables in dreamweaver, which makes amending layouts much easier. I’m find it really difficult to navigation my way around the code. I’ve been finishing off a project for a client where the previous developer has put almost all of a pages HTML within ECHO’s.
