Difference between revisions of "Spring 2020: PHP Programming Lab"
Jump to navigation
Jump to search
| Line 127: | Line 127: | ||
* Today is 03/02/2020 | * Today is 03/02/2020 | ||
* Today is Monday (use l(lowercase L) option to display Day of the week) | * Today is Monday (use l(lowercase L) option to display Day of the week) | ||
| − | |||
(B) Display time in the different format: | (B) Display time in the different format: | ||
* The time is 01:21:20 pm (Time in 12-hour format) | * The time is 01:21:20 pm (Time in 12-hour format) | ||
* The time is 13:21:20 (Time in 24-hour format) | * The time is 13:21:20 (Time in 24-hour format) | ||
| + | (C) Create a Date With mktime() | ||
| style="width: 15%"| Practice Set No. L5 | | style="width: 15%"| Practice Set No. L5 | ||
| | | | ||
Revision as of 18:56, 2 February 2020
- Instructions
- Please be on time to avoid the attendance penalty.
- Turn off(shutdown) your assigned computer after finishing your work (or before you leave the lab).
- Please arrange the chair in proper place while leaving the lab.
- Please put your phone in silent mode.
Contents
Lab 1: Getting Started ( week of 6th/7th January 2020 )
- Brief introduction to PHP [Download]
| Q. NO. | Program | Lab Exercise No. | Remarks |
|---|---|---|---|
| 1 | WAP to print first n even numbers | Practice Set No. 13 | |
| 2 | WAP to find sum of first n odd numbers | Practice Set No. 14 | |
| 3 | WAP to check whether the given number is prime or not | Practice Set No. 12 | |
| 4 | WAP to print the following pattern using nested for loop:* |
Practice Set No. 17 | |
| 5 | WAP to sort an array using built in PHP function | Lab Exercise No. 2 |
Lab 2: ( week of 13th/14th January 2020 )
- Arrays, Strings and Functions in PHP [Download]
| Q. NO. | Program | Lab Exercise No. | Remarks |
|---|---|---|---|
| 1 | Create a PHP page using functions for comparing three integers and print the largest number (function with arguments, function without arguments, function returning value) | Practice Set No. 10 | |
| 2 | Write a function to calculate the factorial of a number(non-negative integer). The function accepts the number as an argument | Practice Set No. 11 | |
| 3 | Write a PHP script that checks whether a passed string is palindrome of not? (A Palindrome is word, phrase, or sequence that reads the same backward as forward. For example: mom, dad, madam, Step on no pets, nurses run | Practice Set No. 15 | |
| 4 | $color = array("white","green","red") Write a PHP script which will display the colors in the following way:
|
Lab Exercise No. 5 | |
| 5 | Write a PHP script which will perform string manipulations using in-built functions. | Practice Set L2 |
Lab 3: ( week of 20th/21st January 2020 )
- Introduction to PHP Form Handling [Download]
| Q. NO. | Program | Lab Exercise No. | Remarks |
|---|---|---|---|
| 1 | Create a form which collects data like Name, Roll Number, Course, Address. Using a submit button send it for processing to a PHP file named "mydata.php". Use HTTP POST method to send the form-data and finally display the submitted data. | Practice Set No. L3 | |
| 2 | Create the same form as Q.NO. 1, and submit using HTTP GET method. | Practice Set No. L3 (2) | |
| 3 | Create a PHP page which accepts string from user. After submission that page displays the reverse of provided string. | Lab Exercise No. 1 | |
| 4 | Write a PHP program to print Fibonacci series using recursion. | Practice Set No. 16 |
Lab 4: ( week of 27th/28th January 2020 )
- To get select data [Download]
- To get radio data [Download]
- To get checkbox data [Download]
- Sample Form for Q. NO. 1 [Form][Code]
| Q. NO. | Program | Lab Exercise No. | Remarks |
|---|---|---|---|
| 1 | Create a form with elements/controls like text, textarea, select, radio button, checkbox, etc. Read the form data, submit it on the same page and display the submitted data. | Practice Set No. L4 | |
| 2 | Create the same form as Q.NO. 1, read the form data in another form named formProcess.php using GET/POST method. | Practice Set No. L4 (2) | |
| 3 | Using switch case and dropdown list display a “Hello” message depending on the language selected in drop down list. | Lab Exercise No. 6 | |
| 4 | Create a simple "birthday countdown" script, the script will count the number of days between current day and birth day. | Lab Exercise No. 4 |
Lab 5: ( week of 03rd/04th February 2020 )
- Read PHP Date and Time from w3schools
| Q. NO. | Program | Lab Exercise No. | Remarks |
|---|---|---|---|
| 1 | (A) Display date in the different format:
(B) Display time in the different format:
(C) Create a Date With mktime() |
Practice Set No. L5 | |
| 2 | Create a simple "birthday countdown" script, the script will count the number of days between current day and birth day using PHP date and time functions. | Lab Exercise No. 4 |