Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

php imp

Uploaded by

Shweta Sahani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

php imp

Uploaded by

Shweta Sahani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Section A: Short Answer Questions (2 × 5 = 10 Marks)

1. Answer the following in brief:


(a) What is PHP? Explain its evolution and significance in web development. (2)
(b) Differentiate between $_GET and $_POST methods in PHP. (2)
(c) Write the syntax for creating a user-defined function in PHP. Provide a basic example. (2)
(d) Explain the concept of dynamic variables in PHP with an example. (2)
(e) What is the use of the foreach() loop in PHP? Explain with an example. (2)

Section B: Medium Answer Questions (5 × 4 = 20 Marks)

2. Write a PHP script to demonstrate:


(a) The use of the if and elseif conditions to determine whether a number is positive,
negative, or zero. (5)

3. Discuss the role of file permissions in PHP. Write a script to check if a file is readable,
writable, and executable. (5)

4. Write a PHP script to create an associative array of five fruits and their prices. Use a loop
to display each fruit and its price in a tabular format. (5)

5. Write a PHP script to handle a form that takes a user’s name and email as input. Validate
the input to ensure:

 The name field is not empty.


 The email is in the correct format.
If the inputs are valid, display them; otherwise, show an error message. (5)

Section C: Long Answer Questions (10 × 3 = 30 Marks)

6. Explain the process of database connectivity in PHP. Write a PHP script to connect to a
MySQL database and perform the following:
(a) Insert a new record into a students table with fields (ID, Name, Age, Email).
(b) Retrieve and display all records from the students table in an HTML table format. (10)

7. Write a PHP script to perform file upload functionality. The script should ensure that:

 The uploaded file is an image (e.g., jpg, png).


 The file size does not exceed 1 MB.
 If valid, the file is stored in a directory called uploads, and a success message is
displayed. Otherwise, show an appropriate error message. (10)

8. Define and explain arrays in PHP. Write a script to create a multi-dimensional array for
storing product details (Product ID, Name, Price, Quantity). Display the array in a tabular
format. Also, calculate the total value of each product (Price × Quantity) and display it in the
table. (10)

You might also like