PHP Interview Questions and Answers

What is PHP?
The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.
What are the differences between Get and post methods?
There are some defference between GET and POST method 1. GET Method have some limit like only 2Kb data able to send for request But in POST method unlimited data can we send 2. when we use GET method requested data show in url but Not in POST method so POST method is good for send sensetive request
What are the differences between require and include?
Both include and require used to include a file but when included file not found Include send Warning where as Require send Fatal Error .
What is use of header() function in php ?

The header() function sends a raw HTTP header to a client.We can use header() 
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen.

What is meant by nl2br()?

Inserts HTML line breaks (<BR />) before all newlines in a strin

How we get IP address of client, previous reference page etc ?
By using $_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER'] etc.

How can we register the variables into a session?
$_SESSION['name'] = 'me';
What are the different types of error in php?

three basic types of runtime errors in PHP:

1. Notices: These are trivial, non-critical errors that PHP encounters while executing a
script for example, accessing a variable that has not yet been defined.
By default, such errors are not displayed to the user at all although 
you can change this default behavior.

2. Warnings: These are more serious errors for example, attempting to include() a file 
which does not exist. By default, these errors are displayed to the user, but they do 
not result in script termination.

3. Fatal errors: These are critical errors  for example, instantiating an object of a non-existent class,
or calling a non-existent function. These errors cause the immediate termination of the script, and PHP 
default behavior is to display them to the user when they take place.

Latest Updates

Ratio and Proportion

175 men can dig a canal of 3150 meters long in 36 days. How many men are required to dig a canal of 3900 meters long in 24 days?

24 men working at 8 hours a day can do a piece of work in 15 days. In how many days can 20 men working at 9 hours a day do the same work?

10 men can lay a road of 75 Km long in 5 days. In how many days can 15 men lay a road of 45 Km long?

Rice costing Rs. 480/- is needed for 8 members for 20 days. What is the cost of rice required for 12 members for 15 days?

The mess charge for 35 students for 24 days is Rs. 6300/-. In how many days will the mess charges be Rs. 3375/- for 25 students?

Time and Work

18 men can dig a well in 10 days. After they have worked for 4 days, how many more men shall be employed to complete the work in 4 days from then?

If 80 men can do a piece of work in 10 days, how many men are required to do the same work in 4 days?

If 80 men can do a piece of work in 10 days, in how many days can 40 men do the same piece of work?

General Computer Knowledge

What kind of material does ‘IC’ in computers made of?

Physics

The force required to produce an acceleration of 4 m/s2 in an object of mass 9 kg is?

Biology

Some seeds have hooks and spines. It helps the seeds to__________?

Physics

Which of the following modes of heat transfer is faster?

Agriculture

Which of the following reproduces from underground stem?

Botany

Lichens are a symbiotic association of?

Physics

The unit of relative density is?

Problems on Ages

The ages of Gyanendra and Jitendra are in the ratio of 12:7 respectively. After 6 years, the ratio of their ages will be 3:2 respectively . find the difference in their ages?

Time and Work

X can do a piece of work in 20 days, while Y can do in 10 days. If Y worked at it for 8 days,then X can finish the remaining work in______.?

Coding-Decoding

In a certain code, BELIEF is written as AFKKDI. How is SELDOM written in that code?