PHP Server-Side Scripting Basics 🖥️🚀

What is Server-Side Scripting?
🔹 Server-side scripting means the code runs on the web server, not in the user's browser.
🔹 The server processes the PHP code and sends plain HTML to the user's browser.
🔹 Unlike JavaScript, which runs on the client-side, PHP handles database interactions, authentication, file handling, and more.
How PHP Works on the Server?
1️⃣ A user requests a .php page (e.g., index.php).
2️⃣ The web server (Apache, Nginx) processes the PHP script.
3️⃣ PHP executes the code, interacts with a database (if needed).
4️⃣ The server sends back the processed HTML to the browser.
✅ Example: Server processes PHP and sends HTML
echo "Hello, World!"; // PHP code executes on the server
?>
🔹 Output in browser:
Hello, World!
Writing Your First PHP Script
🔹 PHP code is written inside tags.
🔹 The default file extension for PHP files is .php.
🔹 Save your script in a web server directory (e.g., htdocs for XAMPP).
Example: Basic PHP Script
// This is a PHP comment
echo "
Date: 2025-03-24 00:00:00.000000