0% found this document useful (0 votes)
6 views

PHP Practicals (2)

The document outlines a practical assignment list for PHP programming, covering fundamental concepts such as displaying text, using variables, performing arithmetic operations, and implementing control structures like if statements and switch cases. It also includes tasks related to loops, arrays, functions, and date/time handling. Each section provides specific exercises to enhance programming skills in PHP.

Uploaded by

aryansuthar194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

PHP Practicals (2)

The document outlines a practical assignment list for PHP programming, covering fundamental concepts such as displaying text, using variables, performing arithmetic operations, and implementing control structures like if statements and switch cases. It also includes tasks related to loops, arrays, functions, and date/time handling. Each section provides specific exercises to enhance programming skills in PHP.

Uploaded by

aryansuthar194
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PHP Practical List

Assignment
_________________________________________
1. Hello World and PHP Info

 Display "Hello, World!" using echo and print.


 Display PHP configuration using phpinfo().

2. Variables and Constants

 Declare and print variables of different types.


 Define and use constants using define().

3. Arithmetic Operations

 Perform arithmetic operations on two numbers and display the


result.
 Calculate the area and perimeter of a rectangle.

4. Use of if, else, elseif

 Check if a number is positive, negative, or zero.


 Find the largest among three numbers.

5. Switch Case

 Write a script to display the day of the week based on a


number (1-7).
 Create a simple calculator using switch-case (add, subtract,
multiply, divide).

6. Loops Practice

 Print even numbers from 1 to 50 using a loop.


 Calculate the factorial of a number using a loop.
 Print the Fibonacci series up to N terms.

7. Nested Loops

 Create a number pyramid using nested loops.


 Display a pattern like:
*
**
***

8. Arrays – More Practice

 Find the maximum and minimum value in an array.


 Search for a value in an array.
 Remove duplicates from an array using array_unique().

9. Associative Arrays

 Create an associative array of countries and capitals.


 Print all key-value pairs using foreach loop.

10. Multidimensional Arrays

 Store and display student details (name, subject, marks).


 Display data using nested loops.

11. Built-in Math Functions

 Use functions like abs(), pow(), sqrt(), round(), ceil(), floor().

12. User-defined Functions – Advanced

 Create a function to check if a number is prime.


 Create a function to reverse a number.
 Create a function to check if a string is a palindrome.

13. String Functions – Extended

 Count the number of vowels in a string.


 Remove white spaces from a string.
 Find the position of a word in a sentence using strpos().

14. Include and Require

 Create two PHP files: one with a message and one that includes
it using include and require.
 Show difference between include() and require().

15. Date and Time Functions – Extended

 Display current day, month, and year separately.


 Show how many days are left until a future date (e.g., New
Year).

You might also like