Reputation: 2552
I have a very basic HTML file, that displays some text, and includes a php file, which also echos very basic text:
My HTML code is in a file called home.html:
<html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include 'footer.php';?>
</body>
</html>
The PHP file is called footer.php:
<?php echo "<p>Test</p>"; ?>
I've installed XAMPP on my Windows machine, and the setup currently looks like:
I'm not too sure what the XAMPP setup entails, but all I do is double click on my html page in my local filesystem, and I see the html text being displayed, but not the PHP.
Is there anything left to do in my local setup to get PHP to work? Do I need to access my home.html webpage from a certain port? If so, how do I do that?
EDIT I have pasted my home.html and footer.php files in C:\xampp\htdocs. My apache is running on port 80. How do I access the home.html? I have tried
but that still doesn't show the php code
EDIT2 I changed my file name to home.php, and accessed it through localhost on port 80 and that seemed to work.
Upvotes: 0
Views: 438
Reputation: 1034
Double clicking will just open it in the browser as HTML and not process as PHP. It looks like Apache is running on port 80. Try these:
As others have pointed out, you also need to use the .php
extension on your filename.
Also, make sure you are saving your file in the correct directory. It would be something like C:/xampp/htdocs/
Upvotes: 0
Reputation: 883
You have to change the filename from home.html to home.php
If not, the php-interpreter is not able to process php-code
Upvotes: 0
Reputation: 59
For PHP functions you need to rename your file to home.php!
I hope I helped you :)
Upvotes: 1