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

Advance PHP

The document provides a comprehensive overview of various programming concepts, primarily focusing on PHP and object-oriented programming principles. Key topics include encapsulation, inheritance, serialization, and web services, along with specific functions like get_class_methods() and get_class_vars(). It also discusses the features of content management systems like Joomla and Drupal, as well as the Document Object Model (DOM) and web services communication models.

Uploaded by

Suraj Tapkir
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)
39 views7 pages

Advance PHP

The document provides a comprehensive overview of various programming concepts, primarily focusing on PHP and object-oriented programming principles. Key topics include encapsulation, inheritance, serialization, and web services, along with specific functions like get_class_methods() and get_class_vars(). It also discusses the features of content management systems like Joomla and Drupal, as well as the Document Object Model (DOM) and web services communication models.

Uploaded by

Suraj Tapkir
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

Q.

A) Short Answer (2 mark )

a) What is Encapsulation?

Ans= Encapsulation is an object-oriented programming principle that bundles data (attributes) and
methods (functions) that operate on the data into a single unit, typically a class. It restricts direct
access to some of an object's components, enhancing data security and integrity.

b) State the purpose of Extends Keyword.

Ans= In PHP, the extends keyword is used to create a subclass that inherits properties and methods
from a parent class, facilitating code reuse and establishing a hierarchical relationship between
classes.

c) What is Serialization?

Ans= Serialization is the process of converting a data structure or object into a format that can be
easily stored or transmitted and later reconstructed. In PHP, the serialize() function generates a
storable representation of a value.

d) What is the use of abstract class?

Ans= An abstract class in PHP serves as a blueprint for other classes. It cannot be instantiated on its
own and must be extended by other classes that implement its abstract methods. This allows for
defining common behaviors that derived classes must implement.

e) Define Template?

Ans= in programming, a template is a feature that allows functions or classes to operate with generic
types, enabling code reuse for different data types without rewriting code for each type.

f) What is set cookie () function?

Ans= The setcookie() function in PHP is used to send a cookie from the server to the client's browser.
Cookies are small files stored on the client's computer that can hold data, such as user preferences,
and are sent with subsequent requests to the same server.

g) What is Serialization?

Ans= Serialization is the process of converting a data structure or object into a format that can be
easily stored or transmitted and later reconstructed. In PHP, the serialize() function generates a
storable representation of a value.

h) What is UDDI?

Ans= UDDI (Universal Description, Discovery, and Integration) is a platform-independent, XML-based


registry for businesses worldwide to list themselves on the internet. It enables the discovery of web
services and their providers.

i) Define class.

Ans= In object-oriented programming, a class is a blueprint for creating objects. It defines a set of
attributes (properties) and methods (functions) that the created objects will have.
j) What is Ajax Script?

Ans= Ajax (Asynchronous JavaScript and XML) is a set of web development techniques that use
various web technologies on the client side to create asynchronous web applications. It allows web
pages to be updated asynchronously by exchanging small amounts of data with the server behind
the scenes, enhancing user experience by enabling web pages to update without reloading.

k) What is Web Services?

Ans= web services are standardized ways of integrating web-based applications using open standards
over an internet protocol backbone. They allow different applications from different sources to
communicate with each other without time-consuming custom coding.

Q.B) Long Answer.

1. What is introspections? Explain any two introspective function?

Ans= introspection in programming refers to the ability of a program to examine the type or
properties of an object at runtime. In PHP, introspection allows you to retrieve information about
classes, interfaces, functions, methods, and extensions.

Two introspective functions in PHP are:

 get_class_methods(): This function returns an array of method names defined in a class. For
example: class MyClass {

public function methodOne() {}

public function methodTwo() {}

$methods = get_class_methods('MyClass');

print_r($methods);

 get_class_vars(): This function returns an associative array of default properties of a class.


For example:

php

class MyClass {

public $var1 = 'value1';

public $var2 = 'value2';

$vars = get_class_vars('MyClass');

print_r($vars);
2. Explain get_class_methods() and get_class_vars() with example in

Ans= As explained above:

 get_class_methods(): Returns an array of method names defined in a class. \

Example: php

class SampleClass {

public function firstMethod() {}

public function secondMethod() {}

$methods = get_class_methods('SampleClass');

print_r($methods);

 get_class_vars(): Returns an associative array of default properties of a class.

Example: php

class SampleClass {

public $propertyOne = 'default1';

public $propertyTwo = 'default2';

$properties = get_class_vars('SampleClass');

print_r($properties);

3. Introspection?

Ans= introspection in programming refers to the ability of a program to examine the type or
properties of an object at runtime. It allows developers to write more flexible and dynamic code by
enabling the program to make decisions based on the structure and behavior of objects during
execution. In PHP, introspection is facilitated through various functions that provide information
about classes, interfaces, functions, methods, and object properties.

For instance, functions like get_class(), get_class_methods(), and get_class_vars() are used to
retrieve information about a class's name, its methods, and its properties, respectively. These
functions are particularly useful for debugging, developing frameworks, or any scenario where
understanding the structure of objects at runtime is necessary.

5. Short note on WSDL.

Ans= WSDL, or Web Services Description Language, is an XML-based interface description language
used for describing the functionalities offered by a web service. It provides a machine-readable
description of how the service can be called, what parameters it expects, and what data structures it
returns. WSDL enables clients to understand and interact with web services by providing all
necessary details about service endpoints, operations, and message formats.
4. Explain features of Joomla/Drupal.

Ans= Both Joomla and Drupal are popular Content Management Systems (CMS) that offer a range of
features to facilitate website development and management.

Joomla Features: Multilingual Support: Joomla offers support for over 70 languages, making it
suitable for creating multilingual websites.

 Search Engine Optimization (SEO): It provides out-of-the-box SEO and SEF (Search Engine
Friendly) features to enhance website visibility on search engines.

 Flexibility: Joomla is versatile, allowing the creation of various types of websites, from blogs
and business websites to intranets and community portals.

 Extensibility: With over 8,000 extensions available, Joomla can be extended to include
additional functionalities as needed.

Drupal Features:

 Modular Architecture: Drupal's modular design allows developers to add or remove features
and functionalities using modules, providing high customization.

 Strong User Management: It offers robust user management features, including roles and
permissions, facilitating the creation of complex user hierarchies.

 Content Types and Views: Drupal enables the creation of various content types and provides
tools to display them in multiple ways, offering flexibility in content presentation.

 Scalability: Known for its scalability, Drupal can handle high-traffic websites and large
amounts of data efficiently.

7. Explain Web Services Communication models.

Ans= Web services communication models define how data is exchanged between a client and a
server. The primary models include:

 Remote Procedure Call (RPC)-Based Communication Model: This model defines a


request/response-based synchronous communication. The client sends a request and waits
for the server to respond before continuing. It is typically implemented with remote objects
to the client application.

 Message-Oriented Communication Model: In this model, messages are exchanged between


clients and servers without the need for a synchronous response. It allows for asynchronous
communication, where the client does not wait for an immediate response from the server.

 Resource-Oriented Communication Model: This model is based on the concept of resources,


each identified by a unique URI. Clients interact with these resources using standard HTTP
methods like GET, POST, PUT, and DELETE.
6. What is Inheritance? Explain with suitable example.

Ans= Inheritance is a fundamental concept in object-oriented programming that allows a class


(referred to as a child or subclass) to inherit properties and methods from another class (referred to
as a parent or superclass). This promotes code reusability and establishes a hierarchical relationship
between classes.

Example in PHP: php

<?php

// Parent class

class Fruit {

public $name;

public $color;

public function __construct($name, $color) {

$this->name = $name;

$this->color = $color;

public function intro() {

echo "The fruit is {$this->name} and the color is {$this->color}.";

// Child class

class Strawberry extends Fruit {

public function message() {

echo "Am I a fruit or a berry? ";

// Create an object of Strawberry

$strawberry = new Strawberry("Strawberry", "red");

$strawberry->message();

$strawberry->intro();

?>
8. What is class and object with example?

Ans= In object-oriented programming, a class is a blueprint for creating objects. It defines a set of
attributes (properties) and methods (functions) that the created objects will have. An object is an
instance of a class; it is a concrete entity based on the class blueprint.

Example in PHP: php

<?php

// Define a class

class Car {

public $brand;

public $color;

public function __construct($brand, $color) {

$this->brand = $brand;

$this->

9. Difference between Get and Post method.

Ans= In object-oriented programming, a class is a blueprint for creating objects. It defines a set of
attributes (properties) and methods (functions) that the objects created from the class will have. An
object is an instance of a class; it represents a specific implementation of the class with actual values.

Example in PHP: php

<?php

// Define a class

class Car {

// Properties

public $brand;

public $color;

// Constructor

public function __construct($brand, $color) {

$this->brand = $brand;

$this->color = $color;

// Method

public function displayInfo() {


10. Write a PHP program which implements Ajax for additional of two numbers.

Ans=

11. Explain Document object model.

Ans= The Document Object Model (DOM) is a programming interface that represents the structure
of HTML and XML documents as a tree of objects. Each node in this tree corresponds to a part of the
document, such as elements, attributes, or text. This hierarchical representation allows programs and
scripts to dynamically access and update the content, structure, and style of documents.

Key Features of the DOM:

 Tree Structure: The document is modeled as a tree with a single root (the document itself)
and branches representing elements, attributes, and text nodes.

 Platform and Language Neutral: The DOM provides a standard interface that can be used
across different programming languages and platforms to interact with the document.

 Dynamic Manipulation: Scripts can modify the document's structure, style, and content on-
the-fly, enabling the creation of dynamic and interactive web pages.

12. How to create object in PHP? Explain with example.

Ans=

You might also like