PHP script not working in HTML file

后端 未结 6 2038
北海茫月
北海茫月 2020-11-27 06:22

I\'m new to PHP. I installed XAMPP and have Apache running. I created helloworld.php in XAMPP\'s htdocs and got PHP to display in my browser. My question is, why does my PHP

6条回答
  •  情书的邮戳
    2020-11-27 06:50

    The php module for apache registers itself as handler for the mime type application/x-httpd-php. And the configuration file apache\conf\extra\httpd-xampp.conf contains the lines

    
        SetHandler application/x-httpd-php
    
    

    which tells the apache that all files having .php as name extension are to be processes by the handler for application/x-httpd-php.
    If you (really) want to have your .html files handled by the php module as well you have to add something similar for .html extensions. (there are other methods to tell the apache which extension maps to which mime type/handler. But FilesMatch/SetHandler is fine.)
    If you want to enable this "feature" for only one directory you can use an .htaccess file to change the configuration for that directory (and its subdirectories).

提交回复
热议问题