What Is PHP and Setting Up XAMPP
What Is PHP and Setting Up XAMPP
PHP is a server-side scripting language designed for the web. It generates HTML on the server, so visitors only ever receive the finished page, never your source code.
How PHP fits in
A request reaches Apache, which hands files ending in .php to the PHP interpreter. The interpreter runs the code, and every echo or return value becomes part of the response sent back to the browser.
Installing XAMPP
XAMPP bundles Apache, PHP, and MySQL into one installer for Windows, macOS, and Linux. Download it from apachefriends.org, run the installer, and start the Apache and MySQL services from the control panel.
Where files live
Apache serves files from the htdocs folder. Create a file there and open it in the browser:
C:\xampp\htdocs\hello.php
Visit http://localhost/hello.php and you see the page the script produced.
Your first PHP file
<?php
echo 'Hello from PHP';
The opening tag enters PHP mode, echo prints text, and the interpreter returns to HTML after the tag. PHP and HTML can mix freely in the same file.
Why XAMPP
One download gives you everything a beginner needs to practice: a web server, the PHP interpreter, and a MySQL database, all managed from one control panel.
Key Points
- PHP runs on the server and outputs HTML.
- XAMPP bundles Apache, PHP, and MySQL.
- Source files live in the htdocs folder.
- php tags switch between PHP and HTML modes.
- echo prints text into the response.