Exercises from the PHP Full Course by Bro Code - a complete beginner's guide to PHP covering everything from variables to database integration.
| # | Category | Description | Exercises |
|---|---|---|---|
| 01 | Basics | Variables, types, arithmetic, math functions | 5 |
| 02 | Control Structures | if/else, switch, for, while loops | 6 |
| 03 | Strings | String manipulation functions | 1 |
| 04 | Arrays | Indexed and associative arrays | 2 |
| 05 | Functions | Custom functions, arguments, return values | 1 |
| 06 | Forms | GET, POST, radio buttons, checkboxes | 6 |
| 07 | Security | Validation, sanitization, hashing, $_SERVER | 3 |
| 08 | Sessions & Cookies | Session management, cookies | 3 |
| 09 | Includes | Code organization with include() | 1 |
| 10 | Database | MySQL connection, CRUD, login system | 3 |
php-course-brocode/
├── index.php # Main navigation page
├── README.md
├── 01-basics/
│ ├── variables.php # Variables & data types
│ ├── arithmetic.php # Arithmetic operators
│ ├── operator-precedence.php # Operator precedence
│ ├── increment-decrement.php # Increment & decrement
│ └── math-functions.php # Built-in math functions
├── 02-control-structures/
│ ├── if-else.php # If/else conditionals
│ ├── if-elseif.php # If/elseif (pay calculator)
│ ├── logical-operators.php # &&, ||, ! operators
│ ├── switch.php # Switch statement
│ ├── for-loops.php # For loops
│ └── while.php # While loops
├── 03-strings/
│ └── string-functions.php # String manipulation
├── 04-arrays/
│ ├── arrays.php # Indexed arrays
│ └── associative-arrays.php # Associative arrays
├── 05-functions/
│ └── functions.php # Custom functions
├── 06-forms/
│ ├── login.php # Login form (POST)
│ ├── calculate-pizzas.php # Pizza order (GET)
│ ├── calculate-pi.php # Circle calculator
│ ├── radio-button.php # Radio buttons
│ ├── checkbox.php # Checkboxes
│ └── isset-empty.php # isset() & empty()
├── 07-security/
│ ├── validate-form.php # Form validation
│ ├── server.php # $_SERVER superglobal
│ └── hash.php # Password hashing
├── 08-sessions-cookies/
│ ├── cookies.php # Cookies
│ ├── session-login.php # Session login
│ └── session-home.php # Session home (logged in)
├── 09-includes/
│ ├── index.php # Include example
│ └── header.html # Included header file
└── 10-database/
├── database-connect.php # Database connection
├── database-crud.php # CRUD operations
└── fakebook.php # Registration system
- OS: WSL (Ubuntu) or any Linux distribution
- Packages: Apache2, PHP, MySQL
sudo apt update && sudo apt upgrade -ysudo apt install apache2 php libapache2-mod-php mysql-server -ysudo service apache2 start
sudo service mysql startCreate your project folder and link it to Apache:
mkdir -p ~/www/php
sudo ln -s ~/www/php /var/www/html/phpcd ~/www/php
git clone git@github.com:rniguel/php-course-brocode.githostname -IOpen in your browser:
http://YOUR_IP/php/php-course-brocode/
sudo mysqlALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'SenhaForte123!';
FLUSH PRIVILEGES;
EXIT;sudo apt install phpmyadmin -yDuring installation:
- Select Apache2
- Choose Yes to configure database
- If password error appears, skip it
ln -s /usr/share/phpmyadmin ~/www/php/phpmyadminAccess at: http://YOUR_IP/php/phpmyadmin
- User: root
- Password: (the one you set above)
Open phpMyAdmin or MySQL CLI and run:
CREATE DATABASE businessdb;
USE businessdb;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
user VARCHAR(50) NOT NULL,
password VARCHAR(255) NOT NULL
);Update the password in 10-database/database-connect.php if yours differs.
sudo service apache2 start # Start Apache
sudo service apache2 restart # Restart Apache
sudo service apache2 status # Check Apache status
sudo service mysql start # Start MySQL
sudo service mysql restart # Restart MySQL
sudo service mysql status # Check MySQL status- Make sure Apache is running:
sudo service apache2 start
- Verify the symlink is correct:
ls -la /var/www/html/php - Make sure files exist in
~/www/php/
- Fix permissions:
chmod -R 755 ~/www/php
- Create the symlink:
ln -s /usr/share/phpmyadmin ~/www/php/phpmyadmin - Fix permissions:
chmod -R 755 /usr/share/phpmyadmin
- Use a stronger password with uppercase, lowercase, numbers, and special characters
- Use root as the username
- Or create a dedicated user:
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'SenhaForte123!';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;- Use your WSL IP (not localhost):
http://YOUR_IP/
ssh-keygen -t ed25519 -C "your-email@example.com"Add the public key to your GitHub account under Settings > SSH keys.
| Technology | Purpose |
|---|---|
| PHP | Server-side scripting |
| Apache | Web server |
| MySQL | Database |
| phpMyAdmin | Database management UI |
| WSL (Ubuntu) | Linux environment on Windows |
- PHP Syntax: Embedding PHP in HTML, variables, data types
- Operators: Arithmetic, logical, comparison, assignment
- Control Flow: if/else, switch, for loops, while loops
- Data Structures: Indexed arrays, associative arrays, array functions
- Functions: Custom functions, parameters, return values
- Forms: Handling GET/POST data, radio buttons, checkboxes
- Security: Input validation, sanitization, password hashing
- State Management: Sessions and cookies
- Code Organization: include() for reusable components
- Database: MySQL connection, CRUD operations, user registration
This project is for educational purposes. Feel free to use it as a reference for learning PHP.