PHP

PHP is a widely-used open source general-purpose scripting language that is especially suited for web development. We have asked professionals to share the job interview experience and here we got some most asked questions.

Q.1 What is type casting in PHP?
Implicit and Explicit Casting
Q.2 Where is session data stored PHP?
PHP Default Session Storage (File System), In PHP, by default session data is stored in files on the server. Each file is named after a cookie that is stored on the client computer.
Q.3 The function used to convert an array into a string is
implode()
Q.4 What is cookies in PHP with example?
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. ... For example, if a cookie was sent with the name "client", a variable is automatically created called $client, containing the cookie value. Note: The setcookie() function must appear BEFORE the tag.
Q.5 What is the simplest method of finding sum of all the elements of an array?
array_sum function
Q.6 What is the difference between print() and echo()?
print() can be used as part of an expression, while echo() can’ t.
Q.7

Find the output of the following script.

function sort_my_array($array){         
return sort ($array );    }       
$a1 =  array(3, 2, 1);          
var_dump( sort_my_array(&$a1)) ;

It will give you the following output.

Error

Q.8

Find the output of following script.

$array  = array('a','b','c','d');
array_walk  ($array,  'glue');
echo $result;

It will give you the following output.

abcd

Q.9

Find the output of following script.

$array = array( 1, 2, 3,5,8,13,21,34, 55);     
$sum =  0;
for ($i  =  0; $i<5;$i++) 
{ 
$sum +=  $array[$array[$i]];
} 
echo $sum;

It will give you the following output.

78

Q.10

Find the output of following script. 

$x = 0;
if($x++)
print "hi";   
else  
print "how are u";

The output will be

how are you

Q.11

Find the output of following script. 

$x = 0;
if($x++)
print "hi";   
else  
print "how are u";

The output will be

how are you

Q.12 How would you store order number (34) in an 'OrderCookie'?
setcookie('OrderCookie',34);
Q.13 What happens when a form submitted to a PHP script contains two elements with the same name?
Value of second element overwrites the first in specific superglobal array
Q.14

Find the output of following script.

echo 'Testing ' . 1  +  2 . '45';

It will give you the following output.

245

Q.15

1. Find the output of following script.

$array1  = array(0.1  =>  'a', 0.2  =>  'b'); 
echo count  ($array1) ;

The output will be 1.

Get Govt. Certified Take Test