theHeman
theHeman

Reputation: 505

How to get Embedded PHP working in HTML?

I am a beginner in PHP and I am trying to embed PHP in HTML as that is how I am going to need it in my project. This one is a very simple code saved as Trial.html

<html>
<head>
    <title>Trial Page</title>
</head>
<body>
    Hello, today is <?php echo "a great day!"; ?>.
</body>
</html>

When I load this page from server (I am running Apache Tomcat 7 locally), Only the HTML part is getting displayed and the PHP part is not. What am I missing? Do I need to include anything else or am I taking a completely wrong approach for this?

Upvotes: 1

Views: 344

Answers (3)

Dinesh Belkare
Dinesh Belkare

Reputation: 631

Rename "Trial.html" to "Trial.php" this is essential when you try to run php code.

Upvotes: 3

Thomas N T
Thomas N T

Reputation: 459

You change file name from trial.html to trial.php

Upvotes: 1

Ralph Melhem
Ralph Melhem

Reputation: 757

You should save your file as .php and run it on a server with php installed on it.

check XAMP to install a local server

EDIT

Just saw that you're running Tomcat, just make sure php is installed, that your server is running, you're running your file from the server And your file is save as .php

Upvotes: 1

Related Questions