Latest Odesk PHP Skill test questions and answers.

Question:
What does the array_combine (a, b) function do?



a. It appends b to a
b. It associates all keys of a with the values of b and returns a new array
c. It returns a new array with all values of b added to the values of a
d. It doesn't exist
e. None of the above

 Question:
With what encoding does chr () work?



a. ASCII
b. UTF-8
c. UTF-16
d. Implementation dependent
e. None of the above


Question:
What is the associativity of +=?



a. left
b. right
c. it is non-associative

Question:
What is true regarding $a + $b where both of them are arrays?



a. Duplicated keys are NOT overwritten
b. $b is appended to $a
c. The + operator is overloaded
d. This produces a syntax error


Question:
Which of the following crypto in PHP returns longest hash value?



a. md5()
b. sha1()
c. crc32()
d. All return same length hash

Question:
Which of the following crypto in PHP returns longest hash value?



a. md5()
b. sha1()
c. crc32()
d. All return same length hash


Question:
What is the output of the following code?

echo '1'.print(2) + 3;



a. 123
b. 321
c. 511
d. 155
e. 432


Question:
What will be the output of following code?

$a = 10;
echo "Value of a = $a";



a. Value of a = 10
b. Value of a = $a
c. Undefined
d. Syntax Error



Question:
Which of the following are useful for method overloading?



a. __call,__get,__set
b. _get,_set,_load
c. __get,__set,__load
d. __overload


Question:
What will be the result of following operation?

print 4<< 5;



a. 3
b. 128
c. 120
d. 6


Question:
What will be the result of the following expression:

6+4 * 9-3



a. 60
b. 87
c. 39
d. 30


Question:
What is the output of the following code?

<?
echo 0500;
?>



a. 100
b. 500
c. 0500
d. 320
e. None of the above


Question:
Which of the following functions output text?



a. echo()
b. print()
c. println()
d. display()


Question:
Which of the following functions output text?



a. echo()
b. print()
c. println()
d. display()


 Question:
Is the ||= operator present in PHP?



a. yes
b. no

 Question:
Which of the following characters are taken care of by htmlspecialchars?



a. <
b. >
c. single quote
d. double quote
e. &
f. All of the above


Question:
Which of the following is not a PHP magic constant?



a. __FUNCTION__
b. __TIME__
c. __FILE__
d. __NAMESPACE__
e. __CLASS__


Question:
You have defined three variables $to, $subject, and $body to send an email. Which of the following methods would you use for sending an email?



a. mail($to,$subject,$body)
b. sendmail($to,$subject,$body)
c. mail(to,subject,body)
d. sendmail(to,subject,body)


Question:
Which of the following is the operator with the lowest precedence?



a. new
b. and
c. , (comma)
d. =


Question:
What will be the output of the following code?

$var = 10;
function fn()
{
   $var = 20;
   return $var;
}
fn();
echo $var;



a. 10
b. 20
c. Undefined Variable
d. Syntax Error


Question:
What will be the output of the following code?

<?php
$s = "Hello world!";
print $s[4];
?>



a. H
b. e
c. l
d. o
e. " " (a space)

Question:
Which of the following type cast is not correct?

<?php
$fig = 23;
$varbl = (real) $fig;
$varb2 = (double) $fig;
$varb3 = (decimal) $fig;
$varb4 = (bool) $fig;
?>



a. real
b. double
c. decimal
d. boolean


Question:
What will be the output of the following code?

$Rent = 250;
function Expenses($Other)
{
   $Rent = 250 + $Other;
   return $Rent;
}
Expenses(50);
echo $Rent;



a. 300
b. 250
c. 200
d. Program will not compile

Question:
What will be the output of the following code?

<?php
echo 30 * 5 . 7;
?>



a. 150 . 7
b. 1507
c. 150.7
d. you can't concatenate integers
e. error will occur


Question:
What is the output of the following code?

<?
echo (2) . (3 * (print 3));
?>



a. 233
b. 29
c. 329
d. 323
e. Syntax error

Question:
What will be the output of the following code?

<?

$a = "printf";
$a ("hello");

?>



a. hello
b. printf hello
c. printf
d. Syntax error
e. None of the above


Question:
Which of the following printing construct/function accepts multiple parameters?



a. echo
b. print
c. printf
d. All of the above


Question:
What will be the output of the following code?

<?
$a = "NULL";
echo !empty ($a);
?>



a. 0
b. 1
c. TRUE
d. FALSE
e. NULL


Question:
Which of the following is not a file related function in PHP?



a. fclose
b. fopen
c. fwrite
d. fgets
e. fappend



 Question:
Which of the following is a correct declaration?



a. static $varb = array(1,'val',3);
b. static $varb = 1+(2*90);
c. static $varb = sqrt(81);
d. static $varb = new Object;


Question:
Can PHP use Gettext?



a. yes
b. no


Question:
What will be the output of the following code?

function fn(&$var)
{
  $var = $var - ($var/10 * 5);
  return $var;
}
echo fn(100);



a. 100
b. 50
c. 98
d. Error message
e. None of the above


Question:
You wrote following script to check for the right category:

<?php
$cate=5;
...
...

if ($cate==5)
{
?>

Correct category!
<?php
} else {
?>
Incorrect category!
<?php
}
?>

What will be the output of the program if value of 'cate' remains 5?



a. Correct category!
b. Incorrect category!
c. Error due to use of invalid operator in line 6:"if ($cate==5)"
d. Error due to incorrect syntax at line 8, 10, 12 and 14


Question:
What is "?:" ?



a. A logical operator
b. A comparison operator
c. A ternary operator
d. A bitwise operator
e. None of the above


Question:
What will be the output of the following code?

<?
echo "5.0" == "5";
?>



a. 0
b. 1
c. 5.0
d. Syntax error
e. None of the above


Question:
What will be the output of the following code?

<?
$foo = 5 + "10 things";
print $foo;
?>



a. 510 things
b. 5 10 things
c. 15 things
d. 15
e. None of the above


Question:
If expire parameter of setCookie function is not specified then:



a. Cookie will never expire.
b. Cookie will expire with closure of the browser
c. Cookie will expire with within 30 minutes
d. Cookie will expire in 24 hours


Question:
Which of the following variables are supported by 'str_replace()' function?



a. Integer
b. String
c. Boolean
d. Array


Question:
What enctype is required for file uploads to work?



a. multipart/form-data
b. multipart
c. file
d. application/octect-stream
e. None of the above

Question:
What enctype is required for file uploads to work?



a. multipart/form-data
b. multipart
c. file
d. application/octect-stream
e. None of the above

Students Tech Life