How to run PHP on PC using XAMPP

Using an editor (Sublime Text), create a php file and place it in the designated folder:


In it I created a php file "progate_practice.php"with the following content. XAMPP's Apache must be on (I usually  click on both Apache and MySQL).

Use a browser and type in "http://localhost/progate_practice.php."  You will see the php result returned.   I have a subfolder I created for this purpose "C:\xampp\htdocs\kaz," but I couldn't let it run from there (I don't know why this does not work).

$menus = array(
array('name' => 'CURRY', 'price' => 9),
array('name' => 'PASTA', 'price' => 12),
array('name' => 'COFFEE', 'price' => 6)

$totalPrice = 0; // Variable to store the total price
foreach ($menus as $menu) {
$price = $menu['price'];
echo $menu['name'].' is $'.$price;
echo '<br>';
// Add each price to $totalPrice
$totalPrice += $price;
echo 'The total price is $'.$totalPrice;


Leave a Reply