Jump to content

Recommended Posts

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"

Link to comment
https://forums.phpfreaks.com/topic/213472-php-addtype/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/213472-php-addtype/#findComment-1111299
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/213472-php-addtype/#findComment-1111317
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.