• New Admissions Open for Career and Placement Courses.

PHP Interview Questions

-> We can choose files from the system and can perform open, read, write operations on one system.
-> We can perform operations on a form like saving data from a form to send data to the server.
-> You can add, delete, modify elements within your database with the help of PHP.
-> We can create cookies and set cookies on the elements.
-> We can put some restrictions on any PHP pages about accessing it.

PEAR is a framework and repository for reusable PHP components. PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries. It also provides a command line interface to install “packages” automatically.

Static Websites:
-> Static website the content is not changed after changes in the script.

Dynamic Websites:
-> Dynamic website’s content is changed after the changes in the script.

To run any program we have to use the PHP command line by writing the file name in it.

PHP script.php

In PHP, all the user-defined functions are not case sensitive, we can call the function written in lowercase by writing in uppercase but other elements are case sensitive.

Escaping to PHP means to distinguish the PHP code from other elements.

Some of the important characteristics of PHP variables include:
• All variables in PHP are denoted with a leading dollar sign ($).
• The last assigned value to a variable is it’s the latest value.
• The variables are assigned value by using = assignment operator, the left side contains variable and the right side contains the value to be assigned to the variables.
• Variables are mostly declared when it needs to be used for assignment.
• The variables aren’t declared with its types already, it doesn’t know about in which type it is going to be used.
• Variables used before they are assigned have default values.

There are 8 data types in PHP which are used to construct the variables:
1. Integers – Integers are whole numbers, without a decimal point, like 4195.
2. Doubles – Doubles are floating-point numbers, like 3.14159 or 49.1.
3. Booleans – Booleans have only two possible values either true or false.
4. NULL − is a special type that only has one value: NULL.
5. Strings – Strings are sequences of characters, like ‘PHP supports string operations.’
6. Arrays – Arrays are like boxes that are named and indexed collections of other values.
7. Objects Instance of the class that is used to access the functions of the class called objects.
8. Resources − Resources are used to store the reference of the resource outside of PHP.

The following rules are needed to be followed while naming a PHP variable:
• Variable names must begin with a letter or underscore character.
• A variable name can consist of numbers, letters, underscores but you cannot use characters like + , – , % , ( , ) . & , etc.

The rules to determine the “truth” of any value which is not already of the Boolean type are:
• If it values is a number it is false or if it’s equal to zero or anything it is true.
• If it’s a value is a string it is false or if its string is equal to ’0’ or anything it is true.
• Values of type NULL are always false.
• If the array contains the value it is false if the array contains no value or anything else it is true.
• Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
• Don’t use double as Booleans.

Null can have only one value assigned to it, the variable has null value means it has no value assigned to it. It can be assigned as follows:

$var = NULL;

The constant NULL is written in the capital but it is case sensitive. We can write it as:

$var = null;

A variable that has been assigned the NULL value consists of the following properties:
• It evaluates to FALSE in a Boolean context.
• It returns FALSE when tested with IsSet() function.

We can use Define() function to get the value of a constant, we can’t change or undefine it. We can use the letter or underscore to use constantly.

When we don’t know the name of the constant and we want the value of it then we can use Constant() to retrieve the value of constant.it may happen in the case when it is stored in a variable or returned by a function.

-> We can use constantly without writing Dollar sign before it.
-> We can define the
-> We can access the constant from anywhere far from any scoping rules.
-> We cannot undefined or redefine the constants.

-> We have to write a dollar sign before a variable to use it.
-> We can define the variable by assignment operation.
-> We can access the variables which are created by functions automatically.
-> We can redefine variables independently.

1.) _LINE_ – we can use it to show the current line number of the file.
2.) _FILE_ – we can use it to show the name and full path of the file .when used in inside include, the name of the file is returned which is included.
3.) _FUNCTION_ – we can use it to show the function name
4.) _CLASS_ – this constant returns the class name.
5.) _METHOD_ – it shows the method name.

Break – We can use the break statement to break the for loop or the switch conditional statements and transfers the control to the next statement.

Continue – We can use continue statement to stop breaking the loop and transfer the control again to the condition.

• Both constructor and class names are the same.
• We can pass everything by value.
• In PHP4 we cannot declare a class as abstract.
• We can’t use static methods and properties in class in PHP4.

• The Constructors are defined as _construct() and Destructor areas District().
• We can pass objects by the reference.
• In PHP5 we can declare the class as abstract.
• We can use static methods and properties in PHP5.

We can use the final class to protect it to be subclassed in the case of creation of immutable class like the String class.we can not declare properties as final only methods can be declared as final.

Operator ’==’ is used to comparing the two objects if they both are instantiated from the same class and can test their attributes and equal values, we use ‘===’ operator to identify that the instances are referencing to the same two objects of the same class.

PHP is server-side language and javascript is a client-side language so both cannot connect directly but javascript can send some variables back to PHP by using URL and PHP can generate some javascript code to be executed by the browser.

Using HTML, it is a client-side language and we can send the data to the server. PHP is a server side language that can execute the server and send the data in the form of strings, arrays objects and can display in HTML.

PHP support 9 primitive data types:
1) Scalar Types:
• Integer
• Boolean
• Float
• String

2) Compound Types:
• Array
• Object
• Callable

3) Special Types:
• Resource
• Null

In PHP, constructor and destructors are called when the object of the class is created and destroyed. A constructor is used to pass the parameters with the creation of the object to initialize the variables of the instance.

Here is an example of constructor and destructor in PHP:


public function setLink(Foo $link){
$this->;link = $link;

public function __destruction() {
echo ‘Destroying: ‘, $this->name, PHP_EOL;

We can use Include() function to transfer one file’s data into another file.it doesn’t stop e\the execution if any error occurs it continues the execution and provides a warning.

We can use Require() to transfer the data of one PHP file to another file here if any error occurs it stops the execution with the fatal error on the screen.

The Require evaluates a file but require_once () does that only if the specified file is not included .required_once is used to include a PHP file into another file. When we have lots of functions than its good to use required_once().

The different types of error in PHP are:
• E_ERROR– A fatal error that causes script termination.
• E_WARNING– It is a runtime error but it won’t stop the script termination.
• E_PARSE– It’s a Compile-time parse error.
• E_NOTICE– It occurs because of runtime error in the code.
• E_CORE_ERROR– Fatal errors that occur during PHP initial startup.
• E_CORE_WARNING– Warnings that occur during PHP initial startup.
• E_COMPILE_ERROR– These are Fatal compile-time errors that indicate a problem with a script.
• E_USER_ERROR– User-generated error message.
• E_USER_WARNING– User-generated warning message.
• E_USER_NOTICE- User-generated notice message.
• E_STRICT– Run-time notices.
• E_RECOVERABLE_ERROR– Catchable fatal error indicating a dangerous error
• E_ALL– Catches all errors and warnings.

It is used in arrays to the value of the current array element in every pass it is assigned to $value and the pointer is transferred to the next one.
foreach (array as value)
code to be executed;

$colors = array(“blue”, “white”, “black”);

foreach ($colors as $value) {
echo “$value

There are 3 types of Arrays in PHP:
1. Indexed Array Indexed arrays are the one that has a numberic index and are in a linear fashion.
2. Associative Array – When the array is indexed with strings it is called an associative array.
3. Multidimensional Array the array that has more than one or arrays containing in it is called multidimensional array and it is accessed by using its indices.

Latest Blog

June 23, 2017

Get Effective PHP Training for Better Career Growth

PHP training is essential for anyone in the developing industry. It is one of the best courses that one can go for making better career plans. It helps you in understanding the various database functional specifications. What you can achieve with effective PHP courses? With PHP courses, you can learn […]

September 28, 2016

Get PHP Training and Acquire Top Paying Job in IT

PHP is the most easy to grasp programming language. It is also known as the powerful scripting language using which the programmers can develop user friendly websites and applications. Developed by RasmusLerdorf in 1995, PHP has become extremely popular and is being used world-wide because it supports almost all operating […]

March 25, 2016

Training in PHP, PHP Training

Why Training? Training is the process of learning the skills you need to do a particular job or activity. Especially in IT field training is required as in IT you are learning a technology where you need to work practically by using the technology to learn it in an effective […]



TOPS JobFest is Happening

50+ IT Cos will hire for 1,000+ Positions

Are you looking for a JOB ?

I`m looking for a job

Thank you, I`m okay



Complete the form

We are waiting for your application!