PHP Lab Programs

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Fall, 2011-12

Department of Computer Science & Engineering


Introduction to PHP using IDE I!"101#
List of Experiments for the Lab
1$ Introduction to %asic H&"' tags$
2$ (rite a Program to c)ec* and print +)et)er a gi,en num%er is e,en or odd$
-$ (rite a program to compute net amount from t)e gi,en .uantit/ purc)ased and
rate per .uantit/$ Discount 0101 is allo+ed if t)e .uantit/ purc)ased e2ceeds
100$
3$ (rite a program to find largest among t)ree num%ers using ternar/ operators$
4$ (rite a program to print sum of digits of a gi,en num%er$ using +)ile loop#
5$ (rite a program to print Fi%onacci series upto a gi,en num%er$
6$ (rite a program to enter num%ers till t)e user +ants$ 7t t)e end it s)ould displa/
t)e count of positi,e, negati,e and 8eros entered$ 9sing do-+)ile loop#
:$ (rite a function count(ords ;str# t)at ta*es an/ string of c)aracters and finds
t)e
<um%er of times eac) +ord occurs$ =ou s)ould ignore t)e distinction %et+een
capital and lo+ercase letters$
>$ Create a form +it) one te2t field and su%mit %uttons for string lengt), string
reverse and uppercase, lowercase, string replace. Display the result
accordingly.
10$ (rite a "enu-Dri,en program to implement a calculator +)ic) performs onl/
addition, su%traction, multiplication and di,ision$ &)e operation s)ould )appen
%ased on t)e user c)oice$ use s+itc) case#
11$ (rite a function to s+ap t+o string ,alues using call %/ ,alue and call %/
references$
12$ (rite a program t)at +ill accept an arra/ of integers as input, and output an arra/
+)ere for eac) item in t)e source arra/, t)e ne+ arra/ +ill perform t)e follo+ing
operations?
For e,en num%ers di,ide %/ 2
For odd num%ers multipl/ %/ -
1-$ Create an associati,e arra/ using t)e countries as *e/s, t)e cities as ,alues and
transform it into 2-dimensional arra/ and displa/ t)e data as a ta%le$
13$ @i,en t+o strings 7 and !, )o+ +ould /ou find out if t)e c)aracters in ! +ere a
su%set of t)e c)aracters in 7A
14$ (rite a program t)at create a file and +rite contents to it and displa/ it$ &)en
append some data to it$
15$ Create a login form +it) t+o te2t fields called BloginC and Bpass+ordC$ ()en user
enters B@algotiasC as a user name and Buni,ersit/C as a pass+ord it s)ould %e
redirected to a (elcome$H&"' page or to Sorr/$H&"' in case of +rong
usernameDpass+ord$
16$ (rite a PHP program using Ea,a Script to con,ert t)e decimal num%er to its
%inar/ e.ui,alent$ =ou must use a form to accept t)e num%er from t)e user$
1:$ (rite a PHP code t)at define class Student +it) attri%utes Foll<o, <ame,
!ranc), and =ear, create - instances of it, sets t)e ,alues of eac) instance
appropriatel/ and print t)e ,alues of all attri%utes$
1>$ (rite a function calculate7,erage ) +)ic) ta*es four int arguments +)ic) are
mar*s for four courses in t)e semester and returns t)eir a,erage as a float$ &)e
calculate7,erage ) function s)ould ta*e onl/ ,alid range for mar*s +)ic) is
%et+een 0 - 100$ If t)e mar*s are out of range is s)ould t)ro+ an
GutGfFangeE2ception and )andles it$
20$ Create a form +it) a te2t %o2 as*ing to enter /our fa,orite cit/ +it) a su%mit
%utton +)en t)e user enters t)e cit/ and clic*s t)e su%mits %utton anot)er p)p
page s)ould %e opened displa/ing B(elcome to t)e cit/C$

You might also like