Q2 L0 Notes Adv PHP
Q2 L0 Notes Adv PHP
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
$this->brand = $brand;
$this->model = $model;
$this->year = $year;
// Method
}.
// Create objects
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.
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.
Ans:- Joomla and Drupal are both popular content management systems (CMS) used for
building and managing websites.
•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.
class Car {
public $brand;
public $model;
$this->brand = $brand;
$this->model = $model;
}
$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");
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.
Overall, XML documents follow a hierarchical structure with nested elements forming a
tree-like structure.