What is the MIME Content-type for PHP files?

2

I am trying to execute a PHP file and I need to know how its MIME Content-type is so that it can be executed correctly in a browser.

What is the MIME Content-type that should be used for .php files?

Greetings and thanks

    
asked by Adrián Garrido Blázquez 31.08.2017 в 20:31
source

1 answer

2

The MIME Content-type for files PHP can be one of the following depending on the context:

text/plain
text/x-php
application/x-php
application/x-httpd-php
application/x-httpd-php-source
  

There is no official MIME type registered in IANA for PHP. IANA List .

PHP provides the function mime_content_type () to detect the MIME Content-type from a file:

$filename = "./info.php";
echo mime_content_type($filename);
// resultado: text/x-php

From the command line of Ubuntu we can also see it

file -i nombre_archivo.php
//Resultado: nombre_archivo.php: text/x-php; charset=us-ascii
    
answered by 31.08.2017 / 20:41
source