Saturday, November 15, 2025
HomeLanguagesHow to execute PHP Script in Website using XAMPP webserver ?

How to execute PHP Script in Website using XAMPP webserver ?

First we have to install the XAMPP/WAMP webserver in our system. Please follow the link to download and install XAMPP/WAMP server. Link https://www.apachefriends.org/download.html

After successful installation, the steps we should follow are-

  • Open XAMPP control panel, if you want to link database to your code then start MySQL otherwise you will need to start Filezilla and Apache

Xampp starts

  • Then open Notepad/Notepad++ or any text editor to write PHP program.

PHP




<?php
echo "Geeks for Geeks";
?>


  • Save you file in path xampp/htdocs/gfg/a.php

  • Then go to your browser and type localhost/gfg/a.php in URL section. It will display the result.

Note: If there are multiple files in your code similarly then you can put all your files in one folder and can run it.

PHP




<?php 
  
// Declare the variable
$x = 20;  
$y = 10;  
  
// Evaluate arithmetic operations
$z = $x + $y; 
$m = $x - $y;
$p = $x * $y; 
$a = $x / $y;
  
// Addition
echo "Sum: ", $z; // Sum: 30
  
// Subtraction
echo "Diff: ", $m; // Diff: 10
  
// Multiplication
echo "Mul: ", $p; // Mul: 200
  
// Division
echo "Div: ", $a; // Div: 2
?>


Type the URL xampp/htdocs/gfg/code/1.php in the browser, it will display the result.


RELATED ARTICLES

Most Popular

Dominic
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6768 POSTS0 COMMENTS
Nicole Veronica
11919 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11990 POSTS0 COMMENTS
Shaida Kate Naidoo
6897 POSTS0 COMMENTS
Ted Musemwa
7149 POSTS0 COMMENTS
Thapelo Manthata
6850 POSTS0 COMMENTS
Umr Jansen
6841 POSTS0 COMMENTS