runeveryday Posted September 15, 2010 Share Posted September 15, 2010 php addtype: "While some users prefer to use PHP in conjunction with the .html extension, keep in mind that doing so will ultimately cause the file to be passed to PHP for parsing every single time an HTML file is requested.Some people may consider this convenient, but it will come at the cost of performance." can't catch up with this paragraph. supposeed a file's suffix is .html,there is no php in it. does it to be passed to PHP for parsing ? if no, why the above says "keep in mind that doing so will ultimately cause the file to be passed to PHP for parsing every single time an HTML file is requested" Quote Link to comment https://forums.phpfreaks.com/topic/213472-php-addtype/ Share on other sites More sharing options...
rwwd Posted September 15, 2010 Share Posted September 15, 2010 php will only parse a file where the <?php?> tags are invoked, otherwise it is ignored by the parser - this would be the same whether the file extension is php or (x)htm(l) - the actual decision is taken by a directive in the apache servers httpd.conf file, this then incurs a work load for the server, and not the parser. At least that's how I have had it explained to me before. Rw Quote Link to comment https://forums.phpfreaks.com/topic/213472-php-addtype/#findComment-1111299 Share on other sites More sharing options...
PFMaBiSmAd Posted September 15, 2010 Share Posted September 15, 2010 If you have setup your web server to parse .html files as php code files, they will be passed through the php language parser every time they are requested (unless the web server has also been setup with a php bytecode/opcode cache) , the same as if they were .php files. When php parses a file it must scan through every group of characters in the file looking for opening/closing php tags, even if there are none. Php is a parsed, tokenized, interpreted language. This is a multi-pass process. The file is scanned for opening/closing php tags. The php code between the php tags is converted into bytecode/opcode tokens. On the second pass, the php bytecode is fetched and interpreted. Anything in the file that is not between php opening/closing tags is literally output during the second interpretation phase. So yes, doing this does add overhead to every file requests, even if the file does not contain any php code. Quote Link to comment https://forums.phpfreaks.com/topic/213472-php-addtype/#findComment-1111317 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.