php AddType directive

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
everydayrun
Forum Commoner
Posts: 51
Joined: Wed Jan 20, 2010 1:30 am

php AddType directive

Post by everydayrun »

AddType directive:
"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 ?
everydayrun
Forum Commoner
Posts: 51
Joined: Wed Jan 20, 2010 1:30 am

Re: php AddType directive

Post by everydayrun »

anyone helps?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php AddType directive

Post by requinix »

If there's no PHP then there's no point making PHP try to run it. In fact, it's worse than letting Apache handle it automatically.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: php AddType directive

Post by John Cartwright »

everydayrun wrote: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 ?
Although the question was already answered, let me just follow up with a more clear response.

If you add .html suffix to to the AddType directive, any and all html files will be interpreted by the PHP engine. Even with the default .php extension, even if there is no PHP code found within the file, it is still interpreted as a PHP file. As such, even though the files will be parsed by PHP, only code within the PHP tags are actually evaluated.

However, I would not consider this a great performance drain (unless you either have extremely high volume of traffic, where you would benefit from caching).
Post Reply