Php – AddType application/x-httpd-php-source

apache-2.2mime-typePHP

I have Apache 2.0, PHP 5.2.4, and this directive in the httpd.conf:

AddType application/x-httpd-php-source .php .php3 .php4 .php5 .php6

AddType directive is used to maps the given filename extensions onto the specified content type. This is the only meaning of this directive.
But why does this method switch off PHP handler, that assigned .php extensions, and I can view source code of scripts in my browser?

And another:

AddType application/x-httpd-php5 .php

Why does this method switch on PHP handler? This simply must send header Content-Type: application/x-httpd- to my browser and this must be only meaning of directive AddType from mod_mime.

I'm confused.

Best Answer

The AddType directive should only affect the clients interpretation of what your sending it. A common one that is used is text/html which most clients will readily accept and interpret for what you want. Different browsers like I.E. Firefox and Chrome can sometimes interpret these headers differently.

A corollary command is AddHandler which affects how the server interprets the scripts.

Your question is a bit difficult to understand. Are you stating that when you use AddType application/x-httpd-php-source .php .php3 .php4 .php5 .php6 that you can see the actual PHP code itself rather than the processed HTML, but with AddType application/x-httpd-php5 .php it works?