recoup8063
recoup8063

Reputation: 4280

PHP Not displaying

So I am developing a webpage and I am starting to dig into PHP. I went to WS3 schools and looked at the example. I copied it over to an html document. When I double clicked on it and it opened in chrome the PHP would not show up.

Here is the example code:

    <!DOCTYPE html>
    <html>
<body>

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

</body>

Upvotes: 0

Views: 17605

Answers (4)

Jonah Johnson
Jonah Johnson

Reputation: 9

Type in the the terminal/console when your navigated into your scripts directory:

php -S localhost:8080

And then go to http://localhost:8080 in your browser

Upvotes: 0

Igor S.
Igor S.

Reputation: 3350

To learn php you need to set up local server:

  1. Install XAMMP (http://www.apachefriends.org/en/xampp-windows.html)
  2. Thne run Apache Server
  3. Put script in htdocs
  4. Point your browser to http : // localhost

Or just use online service like http://ideone.com/

Upvotes: 0

Madara&#39;s Ghost
Madara&#39;s Ghost

Reputation: 174937

You need a functioning web server that can run PHP in order to be able to parse PHP files.

Just writing PHP and opening the resulting HTML file in the browser won't do.

Have a look at quick local environment such as XAMP or WAMP.

Upvotes: 3

draxxxeus
draxxxeus

Reputation: 1523

PHP cannot be directly rendered by the browser. It needs to be interpreted by a server first. For eg: apache.

If you are on windows using something like WAMP, as suggested by Madara, would help

If you are on Linux, install apache

Upvotes: 0

Related Questions