PHP Practical Slips University
PHP Practical Slips University
Write a function to
count the total number of vowels (a,e,i,o,u) from the string. Show the occurrences of each
vowel from the string. Check whether the given string is a palindrome or not, without
using built-in function. (Use radio buttons and the concept of function. Use ‘include’
construct or require stmt.) [25 M]
Q.2 Write a PHP script for the following: Design a form to accept two strings from the user.
Find the first occurrence and the last occurrence of the small string in the large string.
Also count the total number of occurrences of small string in the large string. Provide a
text box to accept a string, which will replace the small string in the large string. (Use
built-in functions) [25 M]
Q.3 Write a PHP script for the following: Design a form to accept two numbers from the user.
Give options to choose the arithmetic operation (use radio buttons). Display the result on
the next form. (Use the concept of function and default parameters. Use ‘include’
construct or require stmt). [25 M]
Q.4 Write a PHP script for the following: Design a form to accept two strings from the user.
Find whether the small string appears at the start of the large string. Provide a text box to
accept the string that will replace all occurrences of small string present in the large
string. Also split the large string into separate words. (Use regular expressions)
[25 M]
Q.5 Write a PHP script for the following: Design a form to accept the details of 5 different
items, such as item code, item name, units sold, rate. Display the bill in the tabular
format. Use only 4 text boxes. (Hint : Use of explode function.) [25 M]
Q.6 Write a PHP script for the following: Design a form to accept two strings. Compare the
two strings using both methods (= = operator &strcmp function). Append second string to
the first string. Accept the position from the user; from where the characters from the first
string are reversed. (Use radio buttons) [25 M]
Q.7 Write a menu driven PHP program to perform the following operations on an associative
array:
i. Display the elements of an array along with the keys.
ii. Display the size of an array
iii. Delete an element from an array from the given index.
iv. Reverse the order of each element’s key-value pair.[Hint: use array_flip()]
v. Traverse the elements in an array in random order [[Hint: use shuffle()].
[25 M]
Q.8 Write a menu driven PHP program to perform the following operations on associative
arrays:
a) Sort the array by values (changing the keys) in ascending, descending order.
b) Also sort the array by values without changing the keys.
c) Filter the odd elements from an array.
d) Sort the different arrays at a glance using single function.
e) Merge the given arrays.
f) Find the Union, intersection& set difference of two arrays. [25 M]
Q.9 Write PHP script to define an interface which has methods area(), volume(). Define
constant PI. Create a class cylinder which implements this interface and calculate area
and volume. [25M]
Q.10 Write class declarations and member function definitions for an employee(code, name,
designation). Design derived classes as emp_account(account_no, joining_date) from
employee and emp_sal(basic_pay, earnings, deduction) from emp_account. Write a menu
driven PHP program a) to build a master table b) to sort all entries c) to search an entry d)
Display salary. [25 M]
Q.11 Derive a class square from class Rectangle. Create one more class circle. Create an
interface with only one method called area(). Implement this interface in all the classes.
Include appropriate data members and constructors in all classes. Write a PHP program to
accept details of a square, circle and rectangle and display the area.
[25 M]
Q.12 Write PHP Script to create a class account(accno,cust_name). Derive two classes from
account as saving_acc(balance, min_amount) and current_acc(balance, min_amount).
Display a menu a) Saving Account b) Current Account For each of this display a menu
with the following options. 1. Create account 2. Deposit 3. Withdrawal
[25 M]
Q.13 Implement calculator to convert distances between (both ways) miles and kilometres.
One mile is about 1.609 kilometres. User interface (distance.html) has one text-input, two
radio-buttons, submit and reset -buttons. Values are posted to PHP-script (distance.php)
which calculates the conversions according the user input. [25 M]
Q.14 Write PHP program to create input form for Grocery that displays List of grocery items
with checkboxes and create a bill according to list of items selected after clicking submit
button. [25 M]
Q.15 Using regular expressions check for the validity of entered email-id. The @ symbol
should not appear more than once. The dot (.) can appear at the most once before @ and
at the most twice or at least once after @ symbol. The substring before @ should not
begin with a digit or underscore or dot or @ or any other special character. (Use explode
and ereg function.). [25 M]
Q.16 Write a PHP program that accept customer name, consumer number and number of
electricity units consumed from an input form and print electricity bill from following
data
For first 50 units – Rs. 3.50/unit
For next 100 units – Rs. 4.00/unit
For next 100 units – Rs. 5.20/unit
For units above 250 – Rs. 6.50/unit
Fixed meter and service charge- Rs. 150/- [25 M]
Q.17 Write a PHP program for course registration of Learner in an institute that accept Name,
Course to be admitted, Mobile number using input form validation such as Name should
be only string of character, mobile number should contain digits with valid length and so
on. and give feedback to Learner with registration details including registration number.
[25 M]
Q.18 Write a PHP script to create a login form with a username and password. Once the user
logs in, the second form should be displayed to accept user details (name, city, phoneno).
If the user doesn’t enter information within a specified time limit, expire his session and
give a warning. [25 M]
Q.19 Write a PHP script to keep track of number of times the web page has been accessed.
[25 M]
Q.20 Write a PHP script to change the preferences of your web page like font style, font size,
font color, background color using cookie. Display selected settings on next web page
and actual implementation (with new settings) on third web page. [25 M]
Q.21 Write a PHP script to create a form to accept student information (name, class, address).
Once the student information is accepted, accept marks in next form (Phy, Bio, Chem,
Maths, Marathi, English).Display the mark sheet for the student in the next form
containing name, class, marks of the subject, total and percentage.[25 M]
Q.22 Write a PHP program to create a shopping mall UI. User must be allowed to do purchase
from two pages. Each page should have a page total. The third page should display a bill,
which consists of a page total of whatever the purchase has been done and print the total.
(Use http session tracking). [25 M]
Q.23 Write a PHP script to create a form to accept customer information (name, address, ph-
no). Once the customer information is accepted, accept product information in the next
form (Product name, qty, rate). Display the bill for the customer in the next form. Bill
should contain the customer information and the information of the products entered.
[25 M]
Q.24 Write a PHP script to accept username and password. If in the first three chances,
username and password entered is correct, then display second form, otherwise display
error message. [25 M]
Q.25 Consider the following entities and their relationships
Emp (emp_no,emp_name,address,phone,salary)
Salary(em_pno, Basic, HR, TA, DA)
Dept (dept_no,dept_name,location)
Emp-Dept are related with one-many relationship Create a RDB for the above and
solve following Using above database.
write a PHP script which will print a salary statement for specified emp_no with
his details. [25 M]
Q.26 Consider the following entities and their relationships Doctor (doc_no, doc_name,
address, city, area) Hospital (hosp_no, hosp_name, hosp_city) Doctor and Hospital are
related with many-many relationship. Create a RDB in 3 NF for the above and solve
following Using above database, write a PHP script which accepts hospital name and
print information about doctors visiting / working in that hospital in tabular format.
[25 M]