PDA

View Full Version : php in html pages, slows down server?


BroChris
05-09-2003, 06:44 PM
I have my website set up as html pages being parsed as php pages. I've heard a lot that this slows down the server, since every html page needs to be executed by the server.

However, does it slow it down any more than having all php pages? If I simply converted all of my files to .php, wouldn't this have the same effect on the server?

arnyinc
05-09-2003, 09:23 PM
I think I read there is a slowdown when the server switches between php and html processing. So if you keep switching it will go slower.

<?php?>
<html>
<?php?>
<html>
<?php?>
<html>
<?php?>
<html>
<?php?>
<html>
<?php?>
<html>
<?php?>
<html>

It all depends on the traffic and size of your page. My opinion is that it's not worth the hassle of making everything pure php when you can just embed the php into html.

firepages
05-10-2003, 01:42 AM
PHP does not 'switch in and out' of PHP/HTML as such , if apache (or some inferior webserver ;)) is told that a file extension is to be parsed by php then the whole page is sent to the PHP parser.

PHP simply ignores anything that is not in <?[php][%] tags and only processes the PHP code but does not jump 'in and out' of parsing as such

As for parsing .html as php. .. if most of your .html pages contain php code then thats fine , but if only say 50% use php then you are placing an unnecc'y load on your server and PHP and yes performance will decrease albeit not a lot, basically the page has to be sent to PHP , parsed (even though there is nothing to parse) and then returned to the browser so its an extra route you should avoid if possible, I think its a matter or percentages ?

BroChris
05-10-2003, 03:49 AM
Nearly all of my files have php in them, as I rely heavily on headers and footers for page layout. My question isn't so much whether or not parsing html as php would slow the server down (since I already know that it does), my question is would it slow the server down more than simply naming the files php in the first place?

firepages
05-10-2003, 04:52 AM
no it wouldnt , the only unnecc'y slowdown would be for .html files with no PHP in them (which I see is not the issue here)

bored
05-16-2003, 07:49 AM
Originally posted by firepages
PHP simply ignores anything that is not in <?[php][%] tags and only processes the PHP code but does not jump 'in and out' of parsing as such

If you DON'T have PHP in MOST fo your pages. The significance of speed is real slight. Like fire said, it ONLY parses between tags.

YES the process starts, but it isnt that large and doesn't take many resources at all to run. I still wouldn't recommend doing it unless the majority of pages contain PHP code.

If they don't you can do something like mapping just '.html' to PHP, leaving .htm open for whatever and only .html pages get parsed through PHP.

I had to do something similar once.