AJAX & PHP Question Bank

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

AJAX

1. Explain the working of Ajax.

AJAX = Asynchronous JavaScript and XML.

AJAX is a technique for creating fast and dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging


small amounts of data with the server behind the scenes. This means that
it is possible to update parts of a web page, without reloading the whole
page.

Classic web pages, (which do not use AJAX) must reload the entire page if
the content should change.

Examples of applications using AJAX: Google Maps, Gmail, Youtube, and


Facebook tabs.

• AJAX makes use of a browser built-in XMLHttpRequest object to request data from a
Web Server and HTML DOM to display or use the data.
• XMLHttpRequest Object : It is an API in the form an object whose methods help in
transfer of data between a web browser and a web server.
• HTML DOM : When a web page is loaded, the browser creates a Document Object
Model of the page.
2. How can we implement Ajax in the application?

3. Explain the various states of request.

4. Explain the use of onreadystatechange event


5. Readystate properties.
6. How does XMLHttpRequest handle the response from the server?
7. Differentiate between get and post

PHP
1. Explain various data types of php

PHP Data Types: Scalar Types

Integer: Integers are whole numbers without any decimal point. They can be positive or
negative.

Float: Floats (also known as floating-point numbers or doubles) represent numbers with decimal
points or numbers in exponential form.

String: Strings represent sequences of characters enclosed in single quotes ('') or double quotes
("")

Boolean: Booleans have only two possible values: true or false. They are often used for
conditions and comparisons.
PHP Data Types: Compound Types
Array: Arrays are used to store multiple values in a single variable. PHP supports indexed arrays,
associative arrays, and multidimensional arrays.

Object: Objects are instances of classes. They contain both data (properties) and methods
(functions)

PHP Data Types: Special Types


NULL: NULL represents a variable with no value or a variable that has been explicitly set
to NULL.

Resource: Resources are special variables that hold references to external resources like
file handles or database connections. They are created and managed by certain
functions.
$file = fopen("example.txt", "r");
2. Explain the scope of the php variables

Global Scope:
 Variables declared outside of any function or class have global scope.
 They can be accessed from anywhere in the script, including inside functions and
classes.
 Global variables can be accessed using the global keyword within functions


3. differentiate between for-each and for-in
4. Explain various types of arrays in php

5. List sorting methods of array & explain any 3 of them


6. List array manipulation methods & explain any 3 of them
7. Differentiate between implode and explode
8. Explain various types of string manipulation methods
9. Explain string searching methods
10. Explain string comparison methods

11. Write a php code to read a file

12. Write a php code to perform crud operation


Ppdf mathi eni

13. Validate form using regular expression

14. What are superglobal variables? What is the use of $_SERVER

15. How we can set and retrieve the cookie


16. How we can manage sessions in php
17. What are classes & object? Write a simple php code to describe Object oriented
php
In object-oriented programming (OOP), a class is a blueprint for creating objects (instances).
It defines the properties (attributes) and behaviors (methods) that objects of that class will
have.

An object is an instance of a class. It is a concrete realization of the class blueprint, with its
own unique state (property values) and behavior (method implementations).

Here's a simple PHP code example to illustrate classes and objects:

```php
<?php
// Define a class
class Car {
// Properties (attributes)
public $make;
public $model;
public $year;

// Constructor method
public function __construct($make, $model, $year) {
$this->make = $make;
$this->model = $model;
$this->year = $year;
}

// Method
public function displayInfo() {
echo "Make: " . $this->make . ", Model: " . $this->model . ", Year: " . $this->year .
"<br>";
}
}

// Create objects (instances) of the Car class


$car1 = new Car("Toyota", "Camry", 2020);
$car2 = new Car("Honda", "Accord", 2019);

// Call methods on objects


$car1->displayInfo(); // Output: Make: Toyota, Model: Camry, Year: 2020
$car2->displayInfo(); // Output: Make: Honda, Model: Accord, Year: 2019
?>

18. With an example explain the use of inheritance


Inheritance is a fundamental concept in object-oriented programming (OOP) that allows a class
(subclass or child class) to inherit properties and methods from another class (superclass or
parent class). This promotes code reuse and enables hierarchical relationships between classes.
19. What is the use of abstract class in php inheritance

An abstract class is a mix between an interface and a class. It can be define functionality as well
as interface

o Classes extending an abstract class must implement all of the abstract methods
defined in the abstract class.
o An abstract class is declared the same way as classes with the addition of the
'abstract' keyword.
20. What is the use of interface in php

You might also like