2

SO i create the most basic php code possible:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>

<?php
echo "hello";
?>

</body>
</html>

I wrote this in notepad and saved it with a .php extension. However I am having an issue where when I open it up with chrome/firefox, it is displaying the code, and not the "hello" from the echo statement. Any idea why this may be happening?

M. Pollino
  • 45
  • 6
  • 2
    You need a web server software (Apache/Nginx/IIS) to serve PHP file, web browser does not interpreter PHP code – catcon Oct 02 '19 at 04:35
  • https://dev.to/nearlythere/what-do-you-need-for-a-php-local-development-environment-1hk4 – Phil Oct 02 '19 at 05:29

2 Answers2

0

You need a php service to handle php extension files.

You can try : AppServ from https://www.appserv.org/en/

After install, place the php file in the root folder (By default C:/AppServ/www). Access http://localhost/{your_file_name}.php to view.

Xavier
  • 9
  • 3
0

You need to install Web server on your computer If you are using windows, will install XAMPP

And then copy a.php and paste into xampp/htdocs/ And run http://localhost/a.php on browser

Note: you will run the Apache on XAMPP control panel xampp

JohnPatch
  • 11
  • 1