PHP komut HTML dosyası çalışmıyor

3 Cevap php

Ben PHP için yeni. Ben XAMPP yüklü ve Apache çalıştırıyorum. Ben XAMPP en htdocs içinde helloworld.php oluşturulan ve benim tarayıcıda görüntülemek için PHP var. Benim sorum, neden benim HTML dosyasında benim PHP komut dosyası benim tarayıcıda göstermek değil mi? Ive kendi PHP yüklü asla. Ben de onu yüklemek gerekir? Bu XAMPP ile çakışıyor. Benim kod aşağıda. Herhangi bir yardım takdir edilecektir. Şimdiden teşekkürler:

<html>
<body>

<?php
echo "Hello PHP World";
?>

</body>
</html>

3 Cevap

XAMPP zaten PHP içerir, ancak ile betik adını sonunda sürece .php bu PHP motoru tarafından işlenecek olası değildir.

Mime türü için işleyici olarak apache kayıtlarının kendisi için php modülü application/x-httpd-php. Ve yapılandırma dosyası apache \ conf \ extra \ httpd-xampp.conf satırları içeren

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>

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).

GÜNCELLEME! ÇÖZÜLDÜ!

Ekleyerek \ xampp \ apache \ conf \ httpd.conf bölümünde ...: apache hizmetini durdurun, sonra c bir değişiklik eklemek

AddType application / x-httpd-php. Html. Htm

Yeniden apache!

Bu kazan 32-bit için geçerli xampp dağılımında büyük bir yağ 'özelliği' gibi görünüyor.


This is exactly the problem I am having. It works fine if you have html and php in 1 file and name it with a php extension. If you name it as html extension then it doesn't work. If you include ANY javascript in the file to use the php variable, doesn't matter if you call it php or html the php code doesn't work. If you find the answer please let me know because I am about to throw my laptop from a very high building.