3

I ran this in chrome browser but it didn't show the expected results... It showed the exact same code which was written

<!DOCTYPE html>
<html>
<body>

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

</body>
</html>

2 Answers2

0

To run PHP code in your browser, you need a server like XAMP, WAMP, etc. I recommend XAMPP as it is quite easy to use. Download XAMPP from here: https://www.apachefriends.org/index.html

After the installation is done, go the the htdocs folder (C:\xampp\htdocs in windows) and paste your .php file there. After that, open XAMPP control panel and start Apache. Open http://localhost/test.php (assuming the filename is test.php) in your browser and see the result. Done!

AD-1
  • 314
  • 17
-1

Before working on PHP Codes. You should know how to run PHP codes in browser.

If you dont have any server then please install some server like XAMPP, WAMP, etc.

Also, If you have installed the server then might be the file you are running on browser has html extension. It should be a .php extension.

& should run using

http://localhost/test.php (If its in htdocs folder)

I suggest you to see the below documentation before working on PHP.

https://codeofaninja.com/2013/06/how-to-run-a-php-script.html

John Doe
  • 1,024
  • 1
  • 1
  • 10