How to run php file in localhost or browser ?

To run PHP in XAMPP, follow these steps:

  1. Open XAMPP Control Panel and start the Apache and MySQL modules.
  2. Open your web browser and go to http://localhost/xampp/.
  3. Click on the "phpMyAdmin" link to open the phpMyAdmin interface.
  4. Create a new database or use an existing one.
  5. Create a new PHP file in the "htdocs" folder of your XAMPP installation. You can use any text editor to create the file (e.g. Notepad, Sublime Text, etc.). Name the file with the .php extension (e.g. myfile.php).
  6. In the PHP file, add your PHP code. For example:

Copy code
<?php echo "Hello, world!"; ?>
  1. Save the PHP file.
  2. Open your web browser and go to http://localhost/myfile.php (replace "myfile" with the name of your PHP file).
  3. If everything is working correctly, you should see the message "Hello, world!" displayed on the web page.

Congratulations! You have successfully run PHP in XAMPP.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!