0% found this document useful (0 votes)
4 views3 pages

php

The document provides an answer key for a course on Web Based Application Development with PHP, covering object-oriented concepts, form creation and validation, and database operations. Key topics include concrete classes, serialization, cookies, sessions, and SQL commands. It also includes examples of PHP code for various functionalities such as constructors, form handling, and database connections.

Uploaded by

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

php

The document provides an answer key for a course on Web Based Application Development with PHP, covering object-oriented concepts, form creation and validation, and database operations. Key topics include concrete classes, serialization, cookies, sessions, and SQL commands. It also includes examples of PHP code for various functionalities such as constructors, form handling, and database connections.

Uploaded by

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

**Web Based Application Development with PHP (22619) - Answer Key**

---

### **Chapter 3: Apply Object Oriented Concept in PHP (CO3)**

**2 Marks Questions:**

**Q1. Describe term concrete class.**


A concrete class is a class that has complete implementation for all its methods.
It can be instantiated to create objects.

**Q2. Describe term Serialization.**


Serialization is the process of converting a PHP object into a string format so it
can be stored or transferred easily. Later, it can be unserialized back into the
original object.

**4 Marks Questions:**

**Q3. Describe parameterized constructor with suitable example.**


A parameterized constructor is a constructor that takes arguments while creating an
object.
```php
class Student {
public $name;
public function __construct($name) {
$this->name = $name;
}
}

$student1 = new Student("Rahul");


echo $student1->name;
```

**Q4. Compare interface and abstract class.**


| Feature | Interface | Abstract Class |
|--------|-----------|----------------|
| Methods | Only method declarations | Can have both declared and defined methods |
| Variables | No variables (constants only) | Can have variables |
| Multiple Inheritance | Supported | Not supported |
| Access Modifiers | All methods are public | Can use public, protected, private |

---

### **Chapter 4: Creating and Validating Forms (CO4)**

**2 Marks Questions:**

**Q1. Define cookies and session.**


- **Cookies** store user data in the browser.
- **Sessions** store data on the server and are more secure.

**Q2. Describe the PHP mail function.**


The `mail()` function in PHP is used to send emails. Syntax:
```php
mail(to, subject, message, headers);
```

**4 Marks Questions:**


**Q3. Difference between GET method and POST method**
| GET | POST |
|-----|------|
| Data sent in URL | Data sent in body |
| Not secure | More secure |
| Limited data length | No data limit |
| Can be bookmarked | Cannot be bookmarked |

**Q4. Suitable example of form having multiple submit buttons:**


```html
<form method="post">
<input type="submit" name="save" value="Save">
<input type="submit" name="delete" value="Delete">
</form>
```
```php
if(isset($_POST['save'])) {
echo "Save clicked";
} elseif(isset($_POST['delete'])) {
echo "Delete clicked";
}
```

**Q5. How to create, modify and delete cookies.**


```php
// Create
setcookie("user", "John", time()+3600);

// Modify
setcookie("user", "Mike", time()+3600);

// Delete
setcookie("user", "", time()-3600);
```

---

### **Chapter 5: Database Operations (CO5)**

**2 Marks Questions:**

**Q1. List the data types supported by MySQL.**


- INT
- VARCHAR
- TEXT
- DATE
- FLOAT
- BOOLEAN

**Q2. Syntax and example of insert SQL command:**


```sql
INSERT INTO students (roll_no, name, city, mobile_no)
VALUES (101, 'Rahul', 'Pune', '9876543210');
```

**4 Marks Questions:**

**Q3. Steps to connect PHP application to MySQL database:**


1. Create connection using `mysqli_connect()`
2. Check the connection
3. Execute query using `mysqli_query()`
4. Close the connection

**Q4. PHP script to insert one record in student registration table:**


```php
$conn = mysqli_connect("localhost", "root", "", "college");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO student (roll_no, name, city, mobile_no) VALUES (101, 'Amit',
'Mumbai', '9123456789')";

if (mysqli_query($conn, $sql)) {
echo "Record inserted successfully";
} else {
echo "Error: " . mysqli_error($conn);
}

mysqli_close($conn);
```

---
Let me know if you need MCQs, fill-in-the-blanks, or explanations in Marathi/Hindi.

You might also like