Professional Documents
Culture Documents
AJAX & PHP Question Bank
AJAX & PHP Question Bank
AJAX & PHP Question Bank
Classic web pages, (which do not use AJAX) must reload the entire page if
the content should change.
• 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?
PHP
1. Explain various data types of php
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)
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
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).
```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>";
}
}
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