This repository contains a structured set of PHP exercises designed to strengthen the fundamentals of programming through practical mini-projects.
The project explores key concepts such as:
- variables and constants
- forms with
POST - arithmetic processing
- conditions with
if / elseif / else - selection with
switch - loops with
for,while, andforeach - arrays and indexed traversal
- mathematical logic
- pattern generation using nested loops
- Fibonacci sequence generation
The codebase is ideal for a student learning how to move from simple syntax to algorithmic reasoning in PHP.
This project was built to practice and demonstrate the ability to:
- understand the core syntax of PHP
- process user input from HTML forms
- manipulate numbers, arrays, and strings
- apply decision-making logic in real cases
- use loops efficiently for repetitive tasks
- generate visual patterns algorithmically
- implement mathematical sequences such as Fibonacci
- write clean educational code for academic presentation
The file Exercice1_2.php handles a form-based student exercise where the user enters personal information and grades, then the program computes:
- total score
- average
- mention / appreciation
- admission result
- major or minor status
- display of notes using different loop structures
- association of subjects with grades using arrays
The file Patterns.php focuses on algorithmic printing and number processing:
- multiplication table
- centered triangle pattern
- square pattern
- even number display
- sum of integers from
1ton - parity test (even / odd)
The file Fibonacci.php implements the Fibonacci sequence:
- iterative approach for performance and clarity
- optional recursive version kept as reference/commented logic
php-exercises/
│
├── Exercice1_2.php # Student form, grades, average, mention, loops, arrays
├── Fibonacci.php # Fibonacci sequence generation
├── Patterns.php # Multiplication table, patterns, parity, sums
└── README.md # Project documentation- PHP
- HTML5
- XAMPP
- Apache Local Server
- VS Code / any code editor
- HTML form for:
- first name
- last name
- age
- three grades
- average and sum calculation
- mention classification:
- Excellente
- Bien
- Assez bien
- Passable
- Échec
- admission decision
- age category:
- majeur
- mineur
- display with:
forwhileforeach
- mapping subject names to marks
- multiplication table generation
- centered triangle with stars
- square pattern
- even numbers extraction
- sum of first integers:
- iterative method
- mathematical formula
- odd/even check
- Fibonacci sequence from
F0upward - efficient iterative construction
- recursive version shown as algorithmic alternative
Copy the folder into:
C:\xampp\htdocs\So the final path becomes:
C:\xampp\htdocs\php-exercisesOpen XAMPP Control Panel and start:
- Apache
Use one of these URLs:
http://localhost/php-exercises/Exercice1_2.php
http://localhost/php-exercises/Patterns.php
http://localhost/php-exercises/Fibonacci.php
To clone and use the project later:
git clone https://github.com/KHALIDMRJ/php-exercises.git
cd php-exercisesThen move it into your local server folder if needed.
After completing this project, a student should be able to:
- create a PHP form and retrieve values with
$_POST - use constants and variables correctly
- structure conditional logic cleanly
- compare loops and know when to use each one
- generate console-like and browser-based outputs
- solve mathematical problems with PHP
- understand iterative vs recursive thinking
This repository is not just a collection of exercises.
It shows progression from basic syntax to real algorithmic thinking.
It demonstrates:
- practical use of PHP fundamentals
- clean decomposition of exercises by theme
- direct relation between theory and implementation
- readiness for lab work, viva explanation, and teacher evaluation
For an academic presentation, this project can be explained as:
A structured PHP training suite designed to reinforce programming logic, form processing, algorithmic reasoning, and problem-solving through practical exercises.
To make the project even stronger in future iterations, you can add:
- CSS styling for better UI
- separated header/footer files
- reusable PHP functions
- input validation and sanitization
- session handling
- modular project structure
- screenshots in the README
- French/English bilingual documentation
Khalid Morjane
Student in Systèmes d’Information & Intelligence Artificielle
This project is intended for educational and academic use.
If you found this project useful, consider adding a star on GitHub to support the work and keep improving the repository.