A collection of 20 essential PHP programs commonly asked in technical interviews β covering strings, arrays, loops, and basic OOP concepts.
- String manipulation
- Array operations
- Mathematical logic
- File handling
- Object-Oriented Programming (OOP)
- Database connection basics
| No | Program Name | Description |
|---|---|---|
| 1 | reverse_string.php | Reverse a given string |
| 2 | palindrome_check.php | Check if a string is a palindrome |
| 3 | factorial.php | Calculate factorial of a number |
| 4 | prime_number.php | Check whether a number is prime |
| 5 | fibonacci_series.php | Print Fibonacci series up to n terms |
| 6 | sum_of_digits.php | Find sum of digits of a number |
| 7 | swap_numbers.php | Swap two numbers without using a third variable |
| 8 | armstrong_number.php | Check if a number is an Armstrong number |
| 9 | check_even_odd.php | Determine if a number is even or odd |
| 10 | find_largest_number.php | Find the largest among three numbers |
| 11 | array_sort.php | Sort an array in ascending order |
| 12 | array_reverse.php | Reverse elements in an array |
| 13 | count_vowels.php | Count vowels in a string |
| 14 | string_word_count.php | Count number of words in a string |
| 15 | remove_duplicates_array.php | Remove duplicates from an array |
| 16 | file_read_write.php | Demonstrate file read and write operations |
| 17 | simple_calculator.php | Perform basic calculator operations (+, -, *, /) |
| 18 | class_object_demo.php | Create a simple PHP class and object |
| 19 | inheritance_demo.php | Example of inheritance in PHP |
| 20 | database_connection.php | Basic MySQL database connection example |
- Install PHP on your system (version 8+ recommended).
- Clone this repository:
git clone https://github.com/Abhinavsathyann/php-technical-interview-programs.git cd php-technical-interview-programs/programs - Run any program:
php factorial.php