Zame
Zame

Reputation: 320

PHP code doesn't show while using Dreamweaver

I create a new HTML file for my project using Dreamweaver and i added a simple php code:

<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?>

</body>
</html>

so far nothing is appearing while i open the file with google chrome and IE, any thoughts?

Upvotes: 1

Views: 1975

Answers (3)

nullability
nullability

Reputation: 10675

PHP has to be executed on the server. Upload it to a web server that supports PHP, or install your own web server locally such as WAMP. You then need to access the file with a URL rather than just opening it. A local URL will look like http://localhost/ or http://127.0.0.1/.

Your file also needs to have the extension .php if it contains PHP code. If you really want to use PHP inside a .html file, your web server will need to be set up specially to handle this.

Upvotes: 4

Fabiano
Fabiano

Reputation: 5199

A good idea to check if your php file is working properly is to load phpinfo function. This function will show details about your PHP installation:

<?php
   phpinfo();
?>

If what you see on the screen is this php code with the entire opening and closing tags (), then you are not running the page with PHP.

Upvotes: 0

JRL
JRL

Reputation: 850

PHP requires a webserver and an interpreter. Browsers cannot handle PHP on its own.

Look at XAMPP

Upvotes: 1

Related Questions