0% found this document useful (0 votes)
51 views7 pages

Q2 L0 Notes Adv PHP

Uploaded by

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

Q2 L0 Notes Adv PHP

Uploaded by

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

Q2

a) Explain class and object with example.

Ans:- In PHP, a class is a blueprint for creating objects. It defines the properties and
methods that the objects of the class will have.

Example:

// Define a class

class Car {

// Properties

public $brand;

public $model;

public $year;

// Constructor

public function __construct($brand, $model, $year) {

$this->brand = $brand;

$this->model = $model;

$this->year = $year;

// Method

public function displayInfo() {

echo "This is a {$this->year} {$this->brand} {$this->model}.";

}.

// Create objects

$car1 = new Car("Toyota", "Camry", 2022);

$car2 = new Car("Honda", "Civic", 2020);


// Accessing object properties

echo $car1->brand; // Output: Toyota

echo $car2->model; // Output: Civic

// Call object method

$car1->displayInfo(); // Output: This is a 2022 Toyota Camry.

b) What is Document object Model in PHP.

Ans:- The Document Object Model (DOM) in PHP is a programming interface for HTML
and XML documents. It represents the structure of the document as a tree of objects,
allowing developers to manipulate the content, structure, and style of the document
dynamically. With the DOM, you can access and modify elements, attributes, and text
content within an HTML or XML document using PHP code.

c) What is SOAP? Explain in detail?

Ans:- SOAP stands for Simple Object Access Protocol. It is a protocol for exchanging
structured information in the implementation of web services. SOAP defines a set of
rules for encoding messages in XML format and sending them over various protocols
such as HTTP, SMTP, or TCP. It allows programs running on different operating systems,
platforms, and programming languages to communicate with each other. SOAP involves
XML for message format, HTTP for message transmission, and WSDL (Web Services
Description Language) for describing the services offered by a web service.

d) Explain features of Joomla / Drupal.

Ans:- Joomla and Drupal are both popular content management systems (CMS) used for
building and managing websites.

Some features of Joomla include:

•-friendly interface for content management and website administration.


 Extensibility through the use of extensions like plugins, modules, and templates.
 Built-in multilingual support for creating websites in multiple languages.
 Powerful user management system with access control levels.
 Support for various content types such as articles, categories, and tags.
Drupal, on the other hand, offers features like:
 Highly customizable and scalable platform suitable for building complex websites
and web applications.
 Flexible content architecture with custom content types, fields, and views.
 Robust user and permission management system.
 Extensive module ecosystem for extending functionality and integrating with third-
party services.
 Active community support and regular updates for security and improvements.
e) Explain with example how to connect database using PHP and Ajax.
Ans:- // PHP code to connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Ajax request handling
if(isset($_POST['data'])){
// Process data
$data = $_POST['data'];
// Perform database operation
$sql = "INSERT INTO table_name (column1, column2) VALUES ('$data', 'value')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
Ajax part
// Ajax code to send data to PHP
var data = "some data";
$.ajax({
type: "POST",
url: "your_php_script.php",
data: {data: data},
success: function(response){
alert(response);
}
});

a) Explain features of Joomal/Drupal.


Ans:- Joomla and Drupal are both content management systems (CMS) used to build
and manage websites. They offer features such as user management, content
creation and editing, theme customization, and extension/plugin support. Joomla is
known for its user-friendly interface and strong community support, while Drupal is
more powerful and flexible, often used for complex websites with specific
requirements.
b) What is SOAP? Explain in detail.
Ans:- SOAP (Simple Object Access Protocol) is a protocol used for exchanging
structured information in the implementation of web services. It relies on XML for its
message format and typically operates over HTTP or SMTP. SOAP messages consist
of an envelope containing a header and a body. The header contains metadata, while
the body contains the actual message content. SOAP allows for remote procedure
calls and messaging between applications in a platform-independent manner.

c) XML MVC framework.


Ans:- XML MVC (Model-View-Controller) framework is a software architectural
pattern used for designing and implementing web applications. In an XML MVC
framework, XML is often used to represent the data model and facilitate
communication between the model, view, and controller components. The model
represents the data and business logic, the view displays the user interface, and the
controller handles user input and updates the model and view accordingly.

d) Difference between GET and POST method.


Ans:- The main difference between the GET and POST methods in HTTP is how data
is sent to the server.

•Get method: Data is sent in the URL as a query string. It is suitable for requests that
retrieve data from the server and have a limited amount of data to send.

•POST method: Data is sent in the body of the HTTP request. It is suitable for
requests that modify data on the server or have a large amount of data to send.
POST requests are more secure and can handle larger amounts of data compared to
GET requests.

e)how to create object in PHP? Explain with example.


Ans:- In PHP, you can create an object using the new keyword followed by the class
name. Here's an example:

class Car {
public $brand;
public $model;

public function __construct($brand, $model) {

$this->brand = $brand;
$this->model = $model;
}

public function displayInfo() {

echo "Brand: " . $this->brand . ", Model: " . $this->model;


}
}

// Creating an object of the Car class


$car = new Car("Toyota", "Camry");
$car->displayInfo(); // Output: Brand: Toyota, Model: Camry

a) What is Document Object Model in PHP?


Ans:- In PHP, the Document Object Model (DOM) represents an XML or HTML
document as a tree structure where each node represents a part of the document,
allowing developers to manipulate its content, structure, and style programmatically.
b) Explain class and object with example.
Ans:- In object-oriented programming, a class is a blueprint for creating objects,
defining their properties (attributes) and behaviors (methods). An object is an
instance of a class. For example:
class Car {
public $color;
public function drive() {
echo "The car is driving.";
}
}

$myCar = new Car();

$myCar->color = "red";
$myCar->drive();
c) Explain Setting Reponse Headers.
Ans:- Setting response headers in PHP is done using the header() function. For
example:
header("Content-Type: application/json");

header("HTTP/1.1 200 OK");

d) Differentiate between GET& POST Methods.

Ans:- The main difference between GET and POST methods in HTTP is how data is sent
to the server:

 GET: Data is sent as part of the URL, visible to users, and limited by the maximum
length of a URL. It's suitable for retrieving data from the server.
 POST: Data is sent in the body of the HTTP request, not visible in the URL, and
can carry larger amounts of data. It's suitable for sending sensitive or large
amounts of data to the server, like form submissions.
e) Explain XML document structure in details.

Ans:- XML document structure consists of the following components:

 Prolog: Optional, includes XML declaration and document type definition.


 Root Element: Contains all other elements and is the top-level element.
 Elements: Represent data or metadata within the document.
 Attributes: Provide additional information about elements.
 Text Content: Data contained within elements.
 Comments and Processing Instructions: Additional information or instructions
for processors.

Overall, XML documents follow a hierarchical structure with nested elements forming a
tree-like structure.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy