PHP cannot execute .php file but .html file I am using php 8.2.27 after installing when I execute index.html it works but index.php displays the text in the file , please who can help.
Your Php file begins with
<?php
?
There can be several reasons for this, depending on your setup.
If you are using MacOs or Windows, I recommend Laravel Herd.
If you are using a LAMP or LEMP stacks you should look to make sure you have set it up properly.
Execute how? file://index.html
@Sinnbeck It display the contents of the file like instead of just Hello world on the browser.
@massel What webserver are you using?
@massel Then you most likely haven't configured it for PHP.
Have you tried running php -S localhost:8000 and then access that url in your browser?
@massel did you configure Apache to hand-off requests for PHP files to an appropriate interpreter, e.g. mod_php or PHP-FPM? Apache doesn't itself know how to interpret PHP.
Please sign in or create an account to participate in this conversation.