Reputation: 4280
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
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
Reputation: 3350
To learn php you need to set up local server:
Or just use online service like http://ideone.com/
Upvotes: 0
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
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