1

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?

4
  • 3
    Try saving as trial.php Commented Oct 20, 2015 at 9:29
  • make sure the file extension ends in .php and make sure you're actually running the file from the server and not running the file itself Commented Oct 20, 2015 at 9:33
  • Is there a particular reason you're using Tomcat? Commented Oct 20, 2015 at 9:34
  • @TZHX I was working on Angular where I was using the same server for some temporary basic things. I made a mistake of using the same one without considering PHP. Commented Oct 20, 2015 at 9:59

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.