1. What is PHP?
PHP is a server-side language used to build:
- Websites ๐
- LMS platforms (like Moodle)
- School portals
๐ PHP runs on a web server, not directly in the browser.
⚙️ 2. What You Need
To run PHP, you need:
- ๐งพ PHP (the language)
- ๐ Web Server (like Apache HTTP Server)
- ๐️ Database (optional – MySQL)
๐ Instead of installing separately, we use XAMPP (all-in-one package)
๐ฆ 3. Install XAMPP (EASIEST METHOD ✅)
What is XAMPP?
XAMPP includes:
- Apache (web server)
- PHP
- MySQL
๐ช Steps:
- Go to ๐ https://www.apachefriends.org
- Download XAMPP
- Install it (Next → Next → Finish)
๐ฅ️ 4. Start Your Server
Open XAMPP Control Panel
Start:
- ✅ Apache
- ✅ MySQL
๐ 5. Create Your First PHP File
Go to:
C:\xampp\htdocs\
Create file:
index.php
✍️ 6. Write PHP Code
<?php
echo "Hello, PHP is working!";
?>
๐ 7. Run in Browser
Open browser and type:
http://localhost/index.php
๐ Output:
Hello, PHP is working!
๐ฅ 8. How It Works (VERY IMPORTANT FOR TEACHING)
Flow:
- Browser requests page
- Apache receives request
- PHP processes code
- Result sent back to browser
๐งช 9. Test PHP Info Page
<?php
phpinfo();
?>
๐ Visit:
http://localhost/index.php
You’ll see full PHP configuration
๐️ 10. Using Database (Optional)
Open:
http://localhost/phpmyadmin
๐ You can:
- Create database
- Manage tables
⚠️ 11. Common Errors & Fixes
❌ localhost not working
๐ Start Apache in XAMPP
❌ Port conflict (Apache not starting)
๐ Change port from 80 → 8080
Access with:
http://localhost:8080
❌ PHP not running (shows code)
๐ Make sure file ends with .php, not .html
๐ง๐ซ 12. Teaching Flow (FOR YOUR CLASS)
๐ข Day 1:
- Install XAMPP
- Start Apache
๐ก Day 2:
- Create PHP file
- Echo statements
๐ต Day 3:
- PHP + HTML
- Forms
๐ด Day 4:
- Connect to database
๐ฏ 13. Student Practice Tasks
- Display your name using PHP
- Create a simple login form
- Connect to MySQL
- Insert student data
๐ก PRO TIP (FOR YOU ๐ฅ)
Since you already work with Moodle:
๐ Moodle = PHP + MySQL
๐ This is exactly the environment you’re installing
๐ BONUS (ADVANCED OPTION)
Instead of XAMPP, you can use:
- WAMP (Windows)
- MAMP (Mac)
No comments:
Post a Comment