Odesk PHP Test Answers 2014

Question (many answers): 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: You have two strings, which you want to concatenate.

$str1 = ‘Have a ‘;
$str2 = ‘Nice Day’;
The fastest way would be:
a. $str1.Concat($str2);
b. $str1.$str2;
c. “$str1$str2”;
d. None of the above

Question: Which of the following pair have non-associative equal precedence?

a. +,-
b. ==,!=
C. «,»
d. &=,|=

Question:Which of the following variables is not related to file uploads?

a. max_file_size
b. max_execution_time
c. post_max_size
d. max_input_time

Question: You have a 2D array in PHP:

$array = array(array(141,151,161), 2,3, array(101, 202, 303));
You want to display all the values in the array The correct way is:
a.
function DisplayArray($array) {
   foreach ($array as $value) {
      if (array_valid($value)) {
         DisplayArray($value);
      } else {
         echo $value. “<br>”;
      }
   }
}

DisplayArray($array);
b.
function DisplayArray($array) {
   for ($array as $value) {
      if (valid_array($value)) {
         DisplayArray($value);
      } else {
         echo $value. “<br>”;
      }
   }
}

DisplayArray($array);
c.
function DisplayArray($array) {
   for ($array as $value) {
      if (is_array($value)) {
         DisplayArray($value);
      } else {
         echo $value. “&ltbr>”;
      }
   }
} 

DisplayArray($array);
d.
function DisplayArray($array) {
   foreach ($array as $value) {
      if (is_array($value)) {
         DisplayArray($value);
      } else {
         echo $value “&ltbr>”;
      }
   }
}

DisplayArray($array);
Right answer: d.

Question: Multiple select/load is possible with:

a. Checkbox
b. Select
c. File
d. All of the above

Question: The following php variables are declared:

$company = ‘ABS Ltd’;
$$company =‘, Sydney’;
Which of the following is not a correct way of printing ‘ABS Ltd. Sydney’?
a. echo “$company $$company”;
b. echo “$company ${$company}”;
c. echo “$company ${‘ABS Ltd‘}“;
d. echo “$company {$$company}”;

Question (many answers)

We have two variable definitions:
1. 023
2. x23
Choose the correct options:
a. 1 is octal
b. 2 is hexadecimal
c. 2 is octal
d. 1 is hexadecimal

Question: Which of the following is a predefined constant?

a. TRUE
b. FALSE
c. NULL
d. _FILE_
e. CONSTANT

Question (many answers): Which of the following variable names are invalid?

a. $var_1
b. $var1
c. $var-1
d. $var/1
e. $vl

Question (many answers): Which of the following are not considered as boolean False?

a. FALSE
b. 0
c. “0”
d. “FALSE”
e. 1
f. NULL

Question: Which of the following regular expressions can be used to check the validity of an e-mail addresss?

a. ^[^@ ]+@[^@ ]+\.[“@ ]+$
b. ^[^@ ]+@[^@ ]+[^@ ]+$
c. $[^@ ]+@[^@ ]+\[^@ ]+^
d. $[^@ ]+@[^@ ]+[^@ ]+^

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

$fig=23;
$varbl= (real) $fig;
$varb2 = (double) $flg;
$varb3 = (decimal) $flg;
$varb4 = (bool) $fig;
a. real
b. double
c. decimal
d. boolean

Question: Which of the following statements is not true with regard to abstract classes in php5?

a. Abstract classes are introduced in PHP5
b. A class with a single abstract method must be declared abstract
c. Abstract class can contain non abstract methods
d. Abstract method must have method definition and can have optional empty braces following it

Question: What do you infer from the following code?

$str = ‘Dear Customer,\nThanks for your query. We will reply very soon\n Regards,\n Customer Service Agent’;
print $str;
a. Only first \n character will be recognised and new line will be inserted
b. Last \n will not be recognised and only first two parts will come in new lines
c. All the \n will work and text will be printed on respective new lines.
d. All will be printed on one line irrespective of the \n.

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: What will be the output of the following code?

$a = 10;
if($a > 5 OR < 15)
echo “true”;
else
echo “false”
a. true
b. false
c. No output
d. Parse Error

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: You need to check the size of a file in PHP function.

$size=X(filename);
Which function will suitably replace ‘X’ ?
a. filesize
b. size
c. sizeofFile
d. getSize

Question: Which of the following text manipulation functions is supported by PHP?

a. strtoupper()
b. ucfirst()
c. strtolower()
d. str_split()
e. All of the above

Question: Which of the following is a correct declaration?

a. static $varb = array(1 ,‘var, 3);
b. static $varb = 1+(2*9O);
c. static $varb = sqrt(81);
d. static $varb = new Object;

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

1<?php
2 $cate=5
3 …
4 …
5
6 if ($cate==5)
7 {
8 ?>
9 Correct category!
10 <?php
11 } else {
12 ?>
13 Incorrect category!
14 <?php
15 }
16 ?>
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: If visibility is not defined for a method/member then it is treated as public static.

a. True
b. False

Question (many answers): Which of the following statements is incorrect with regard to interfaces?

a. A class can implement multiple interfaces
b. An abstract class cannot implement multiple interlaces
c. An interlace can extend multiple interfaces
d. Methods with same name, arguments, and sequence can exist in the different interlaces implemented by a class

Question: Which of the following is a Ternary Operator?

a. &
b. =
c. : ?
d. ? :
e. +=
f. &&

Question: Which of the following are the valid PHP data types?

a. resource
b. null
c. boolean
d. string
e. Both a and c
f. Both c and d
g. All of the above

Question: You are using sessions and session_register() to register objects. These objects are serialized automatically at the end of each PHP page and are de-serialized automatically on each of the following pages Is this true or false?

a. True
b. False

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 result of the following expression:

6+4 * 9-3
a. 60
b. 87
c. 39
d. 30

Question: Does php 5 support exceptions?

a. Yes
b. No

Question (many answers): Which of the following printing construct/function accepts multiple parameters?

a. echo
b. print
c. printf
d. Allof the above

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: Which of the following is not true regarding XForms?

a. PHP provides support for XForm
b. It can be used on PDF documents
c. The data is sent in XML format
d. The action and method parameters are defined in the body

Question: How would you start a session?

a. session(start);
b. session();
c. session_start();
d. begin_sesion();

Question: How would you store order number (34) in an OrderCookie’?

a. setcookie(«OrderCookie”, 34);
b. makeCookie(”OrderCookie”, 34);
c. Cookie(«OrderCookie”, 34);
d. OrderCookie(34);

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

function fn(&$var) {
   $var = $var - ($var/l0*5);
   return $var;
)
echo fn(100);
a.100
b. 50
c. 98
d. Error message
e. None of the above

Question: What will be the result of following operation?

print 4 << 5;
a. 3
b. 128
c. 120
d. 6

Question: Which of the following is not supported in PHP5?

a. Type Hinting
b. Reflection
c. Magic Methods
d. Muftiple Inheritance
e. Object Cloning

Question: Which of the following is not a valid PHP parser tag?

a. script
b. ?p
c. %
d. ?php

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: You need to keep an eye on the existing number of objects of a given class without introducing a non-class member variable.Which of the following makes this happen?

a. Add a member variable that gets incremented in the default constructor and decremented in the destructor
b. Add a local variable that gets incremented in each constructor and decremented in the destructor
c. Add a static member variable that gets incremented in each constructor and decremented in the destructor
d. This cannot be accomplished since the creation of objects is being done dynamically via “new”

Question: Which of the following multithreaded servers allow PHP as a plug-in?

a. Netscape FastTrack
b. Microsoft’s Internet Information Server
c. O’Reilly’s WebSite Pro
d. Allof the above

Question: Which of the following is used to maintain the value of a variable over different pages?

a. static
b. global
c. session_register()
d. Noneoftheabove

Question: Which of the following variable declarations within a class is invalid in PHP5?

a. private $type = ‘moderate’;
b. internal $term = 3;
c. public $amnt = ‘500’;
d. protected $name = ‘Quantas Private Limited’;

Question: Consider the following two statements:

1 while (expr) statement
2 while (expr): statement endwhile;
Which of the following are true in context of the given statements?
a. 1 is correct and 2 is wrong
b. 1 is wrong and 2 is correct
c. Both 1 & 2 are wrong
d. Both 1 & 2 are correct

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: What is the output of the following code?

function vec_add (&Sa, Sb) {
   $a[X] += $b[’x’];
   $a[y] += $b[’y’];
   $a[Z] += $b['Z'];
}
$a = array (x => 3, y => 2, z => 5);
$b = array (x => 9, y => 3, z => -7);

vec_add (&$a, $b);
print_r ($a);
a. Array
(
[X] => 9
[y] => 3
[Z] => -7
b. Array
[x] => 3
[y] => 2
[z] => 5
c. Array
[xJ =>12
[yJ => 5
[z] => -2
d. Error
e. None of the above

Question: In your PHP application you need to open a file. You want the application to issue a warning and continue execution, in case the file is not found The ideal function to be used is:

a. include()
b. require()
c. nowarn()
d. getFile(false)

Question (many answers); Which of the the following are PHP file upload related functions?

a. upload_file()
b. is_uploaded_file()
c. move_uploaded_file()
d. Noneoftheabove

Question: Which of the following attribute is needed for file upload via form?

a. enctype=”multipart/formdata”
b. enctype=”singlepart/data’
c. enctype=»file”
d. enctype=»form-data/file”

Question: Variable/functions in PHP don’t work directly with:

a. echo()
b. isset()
c. print()
d. All of the above

Question: Which of the following is a PHP resource?

a. Domxml document
b. Odbc link
c. File
d. Allot the above

Question: The inbuilt function to get the number of parameters passed is:

a. arg_num()
b. func_args_count()
c. func_num_args()
d. None of the above

Question: For the following code:

function Expenses() {
   function Salary() {
      function Loan() {
         function Balance() {
         }
      }
   }
}
Which of the following sequence will run successfully?
a. Expenses();Salary();Loan; Balance();
b. Salary();Expenses();Loan(); Balance();
c. Expenses();Salary();Balance();Loan();
d. Balance();Loan();Salary(); Expenses();

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

echo 30 * 5.7
a. 150.7
b. 1507
c. 171
d. you can’t concatenate integers
e. error will occur

Question: Which of the following is correct with regard to echo and print?

a. echo is a construct and print is a function
b. echo is a function and print is a construct
c. Both are functions
d. Both are constructs

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 variables are supported by ‘str_replace’ function?

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

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

a. _call,_get,_set
b. _get,_set,_load
c. _get,_set,_isset
d. _overload

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

var_dump (3*4);
a. int(3*4)
b. int(12)
c. 3*4
d. 12
e. None of the above

Question: You need to count the number of parameters given in the URL by a POST operation. The correct way is:

a. count($POST_VARS);
b. count($POST_VARS_PARAM);
c. count($_POST);
d. count($HTTP_POST_PARAM);

Question: Consider the following class:

1 class Insurance
2 {
3 function clsName()
4 {
5 echo get_class($this);
6 }
7 }
8 $cl = new Insurance();
9 Scl->clsName();
10 lnsurance::clsName();
Which of the following Lines should be commented to print the class name without errors?
a. Line 8 and 9
b. Line 10
c. Line 9 and 10
d. All the three lines 8,9, and 10 should be left as it is.

Question: Which of the following statement is not correct for PHP?

a. it is a server side scripting language
b. A php file may contain text, html tags or scripts
c. it can run on windows and Linux systems only
d. it is compatible with most of the common servers used today

Question: Which of the following functions output text?

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

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

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

Question: The value of a local variable of a function has to be retained over multiple calls to that function. How should that variable be declared?

a. local
b. global
c. static
d. None of the above

Question: Does PHP provide the goto keyword in latest version?


a. Yes
b. No

Ques:     Which composite data types are supported by php?
Ans:     Array
Ques:     The default value of register_globals in PHP is:
Ans:     Off
Ques:     Which of the following is not a valid PHP connection status?
Ans:     open
Ques:     Choose the correct statement:
Ans:      include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
Ques:     If the session_cache_expire() is not set, then by default the session cache will expire after:
Ans:     3 hrs
Ques:     What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Ans:     It will print 1
Ques:     What is true regarding this code?
Ans:     setcookie will return true
Ques:     Which of the following is not a correct way of printing text in php5?
Ans:     echo "Plain text";
Ques:     Which of the following is not the correct way of starting a session?
Ans:     session_initiate()
                                                                                                                      
Ques:     Which of the following functions do you need to implement HTTP Basic Authentication?
Ans:     None of the above
Ques:     Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Ans:     STDPRT
Ques:     Which of the following statements is correct with regard to final and abstract?
Ans:     a. An abstract class cannot have final methods
Ques:     State whether True or False

Paamayim Nekudotayim operator allows access only to the static members of a class?
Ans:     True

Ques:     Which of the following statements is true with regard to comparisons in PHP5?
Ans:     With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

Ques:     Which of the following built-in function assist in checking if actually the function exists or not?
Ans:     function_exists
Ques:     What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Ans:     1
Ques:     What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";
Ans:     5 31 7.5
Ques:     Which of the following is a not a correct way of commenting in php?
Ans:     /#PHP Comment
Ques:     Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?
Ans:     18
Ques:     Which of the following is the correct way of specifying default value?
Ans:     function GetDiscount($Type = "Special") { . . . }
Ques:     With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>
What will be the output on running the script?
Ans:     Error message will be printed
Ques:     What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Ques:     Late PHP versions support remote file accessing for the functions:
Ans:     include_once()
          require_once()
both of them
Ques:     You have designed a user login form as follows:
User Name:  
Password:  
How can you access the username entered by the user in the 'Validate.php' webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables('p', 'p_');
$var= $p_username;
Ans:      Both of them
Ques:     Which of the following does not represent logical AND operator in PHP?
Ans:     &amp
Ques:     Which of the following is not true for a persistent connection?
Ans:     These can't be converted to non-persistent connections
Ques:     Which of the following are invalid data types in PHP?
Ans:     char
Ques:     The Manager and Office classes are as follows:
class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace '???' to obtain the value of printName() function?
Ans:     $ofc->getManager()->printName();
Ques:     The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
Ans:     public function getName(){}
Ques:     Which of the following variable declarations within a class is invalid in PHP5?
Ans:     var $term =3;
Ques:     What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Ans:     bb
Ques:     For the following code:
the output will be:
Ans:     171
Ques:     What is the result of the following expression?
Ans:     5+2 * 4+6
Ques:     What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Ans:     -1299
Ques:     What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Ans:     a b
Ques:    What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Ans:     0
Ques:     What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans:     true
Ques:     What will be the output of the following code?
echo 126;
Ans:     126
Ques:     Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Ans:     1 

Ques:     Which composite data types are supported by php?
Ans:     Array
Ques:     The default value of register_globals in PHP is:
Ans:     Off
Ques:     Which of the following is not a valid PHP connection status?
Ans:     open
Ques:     Choose the correct statement:
Ans:      include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
Ques:     If the session_cache_expire() is not set, then by default the session cache will expire after:
Ans:     3 hrs
Ques:     What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Ans:     It will print 1
Ques:     What is true regarding this code?
Ans:     setcookie will return true
Ques:     Which of the following is not a correct way of printing text in php5?
Ans:     echo "Plain text";
Ques:     Which of the following is not the correct way of starting a session?
Ans:     session_initiate()
                                                                                                                      
Ques:     Which of the following functions do you need to implement HTTP Basic Authentication?
Ans:     None of the above
Ques:     Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Ans:     STDPRT
Ques:     Which of the following statements is correct with regard to final and abstract?
Ans:     a. An abstract class cannot have final methods
Ques:     State whether True or False

Paamayim Nekudotayim operator allows access only to the static members of a class?
Ans:     True

Ques:     Which of the following statements is true with regard to comparisons in PHP5?
Ans:     With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.

Ques:     Which of the following built-in function assist in checking if actually the function exists or not?
Ans:     function_exists
Ques:     What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Ans:     1
Ques:     What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";
Ans:     5 31 7.5
Ques:     Which of the following is a not a correct way of commenting in php?
Ans:     /#PHP Comment
Ques:     Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?
Ans:     18
Ques:     Which of the following is the correct way of specifying default value?
Ans:     function GetDiscount($Type = "Special") { . . . }
Ques:     With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>
What will be the output on running the script?
Ans:     Error message will be printed
Ques:     What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Ques:     Late PHP versions support remote file accessing for the functions:
Ans:     include_once()
          require_once()
both of them
Ques:     You have designed a user login form as follows:
User Name:  
Password:  
How can you access the username entered by the user in the 'Validate.php' webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables('p', 'p_');
$var= $p_username;
Ans:      Both of them
Ques:     Which of the following does not represent logical AND operator in PHP?
Ans:     &amp
Ques:     Which of the following is not true for a persistent connection?
Ans:     These can't be converted to non-persistent connections
Ques:     Which of the following are invalid data types in PHP?
Ans:     char
Ques:     The Manager and Office classes are as follows:
class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace '???' to obtain the value of printName() function?
Ans:     $ofc->getManager()->printName();
Ques:     The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
Ans:     public function getName(){}
Ques:     Which of the following variable declarations within a class is invalid in PHP5?
Ans:     var $term =3;
Ques:     What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];
Ans:     bb
Ques:     For the following code:
the output will be:
Ans:     171
Ques:     What is the result of the following expression?
Ans:     5+2 * 4+6
Ques:     What will be the output of following code?
$var = 1 + "-1.3e3";
echo $var;
Ans:     -1299
Ques:     What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";
Ans:     a b
Ques:    What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Ans:     0
Ques:     What will be the ouput of the following code?
if (-1)
print "true";
else
print "false";
?>
Ans:     true
Ques:     What will be the output of the following code?
echo 126;
Ans:     126
Ques:     Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Ans:     1 

 1. Question: What is true regarding this code?
Answer: setcookie will return true
2. Question: Which of the following is not a correct way of printing text in php5?
Answer: echo “Plain text”;
3. Question: Which of the following is not the correct way of starting a session?
Answer: session_initiate()
4. Question: Which of the following functions do you need to implement HTTP Basic Authentication?
Answer: None of the above
5. Question: Which of the following Command Line Interface constant is not defined in the CLI SAPI?
Answer: STDPRT
6. Question: Which of the following statements is correct with regard to final and abstract?
Answer: a. An abstract class cannot have final methods
7. Question: Which composite data types are supported by php?
Answer: Array
8. Question: The default value of register_globals in PHP is:
Answer: Off
9. Question: Which of the following is not a valid PHP connection status?
Answer: open
10. Question: Choose the correct statement:
Answer: include() includes and evaluates a specific file
require_once() includes and evaluates a specific file only if it has not been included before
11. Question: If the session_cache_expire() is not set, then by default the session cache will expire after:
Answer: 3 hrs
12. Question: What will be the output of the following script?
$count=50;
Paamayim Nekudotayim operator allows access only to the static members of a class?
Paamayim Nekudotayim operator allows access only to the static members of a class?
Answer: function_exists
$i=4;
User Name:
Password:
class Manager{
Answer: 5+2 * 4+6
$var = 1 + “-1.3e3″;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
Answer: It will print 1
13. Question: State whether True or False
Answer: True
14. Question: Which of the following statements is true with regard to comparisons in PHP5?
Answer: With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
15. Question: What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a ="="">
Answer: 1
16. Question: What will be the output of the following code?
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;
Answer: 5 31 7.5
17. Question: Which of the following is a not a correct way of commenting in php?
Answer: /#PHP Comment
18. Question: Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?
Answer: 18
19. Question: Which of the following is the correct way of specifying default value?
Answer: function GetDiscount($Type = “Special”) { . . . }
20. Question: With reference to the following php script:
print ‘Text Line1′
print ‘Text Line2′
?>
What will be the output on running the script?
Answer: Error message will be printed
21. Question: What will be the ouput of the following code?
for ($i = 0; $i < i ="="">
0134
Question: Late PHP versions support remote file accessing for the functions:
Answer: include_once()
require_once()
both of them
22. Question: You have designed a user login form as follows:
How can you access the username entered by the user in the ‘Validate.php’ webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables(‘p’, ‘p_’);
$var= $p_username;
Answer: Both of them
23. Question: Which of the following does not represent logical AND operator in PHP?
Answer: &amp
24. Question: Which of the following is not true for a persistent connection?
Answer: These can’t be converted to non-persistent connections
25. Question: Which of the following are invalid data types in PHP?
Answer: char
26. Question: The Manager and Office classes are as follows:
function printName() {
echo “Manager”;
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace ‘???’ to obtain the value of printName() function?
Answer: $ofc->getManager()->printName();
27. Question: The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
Answer: public function getName(){}
28. Question: Which of the following variable declarations within a class is invalid in PHP5?
Answer: var $term =3;
29. Question: What will be the output of following code?
$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];
Answer: bb
30. Question: For the following code:
the output will be:
Answer: 171
31. Question: What is the result of the following expression?
Question: What will be the output of following code?
echo $var;
Answer: -1299
32. Question: What will be the output of following code?
$var1=”a”;
$$var1=”b”;
echo “$var1 $a”;
Answer: a b
33. Question:What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
Answer: 0
34. Question: What will be the ouput of the following code?
if (-1)
print “true”;
else
print “false”;
?>
Answer: true
35. Question: What will be the output of the following code?
echo 12 . 6;
Answer: 126

36. Question: Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
Answer: 1


Ques: The setrawcookie() method of setting cookies is different from PHP standard method of cookie setting as:
a. It does not allow expiry time to be set
b. It can be used only once
c. It does not URL-ENCODE the value on its own
d.It does not allow domain setting
Ans: C
Ques: You need to keep an eye on the existing number of objects of a given class without introducing a non-class varibale. which of the following makes this happen?
a. Add a member varibale that gets incremented in the default constructer and decremented the destructer.
b. Add a local variable that gets incremented in each constructer and decremented in the desructer
c. Add a static member variable that gets incremented in each constructer and decreented in the destructor
d. This cannot be accomplished since the creation of objects is being done dynamically via “new”
Ans: c
Ques: which of the following variable declaration within a class is invalid in PHP5?
a. private $type = “moderate”;
b. var $term = 3;
c. public $amn = “500″;
d. protected $name = ‘Quantes Private Limited’;
Ans: d
Ques: which of the following is not valid PHP parser tag?
a. script
b. ?p
c. %
d. ?php;
Ans: c
Ques: How can you hide the fact that web pages are written in PHP?
a. By using AddType application/X-httpd-php asp
b. Specify all file names without any dot and extension
c. By using .htaccess diretive in Apeche
d. All of the above
Ans: C
Ques: What is the output of the following code?
$a = 3;
$b = 2;
echo (int)$a/(int)$b
?>
a. 1
b. 1.5
c. 2
d. 3
e. Eroor
Ans: b

Ques: Which one is correct?
a. $s = fwrite (“a string here”);
b. $s = fwrite ($fp,”a string here”);
c. $s = fwrite (“a string here”,$fp);
d. non of the above
Ans: b
Ques: Which of the following set of operations is not valid in PHP 5?
a. >, >=
b. =,==
c. !==,!==
d. +=, *=
Ans: C
Ques: Late PHP version support remote file accessing for the functions:
a. include()
b. include_once()
c. require_once()
d. All of the above
Ans: D

Ques: What will be the output of the following script?
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument()
?>
a. It will print 50
b. It will print 51
c. It will print 52
d. It will print 1
Ans: D
Ques: which of the following are used for code reuse?
a. Loops
b. functions
c. Database
d. include files
Ans: B,D
Ques: which of the following is the corect way of specifying default value?
a. Function GetDiscount($Type = “Special”) {………}
b. Function GetDiscount(Type := “Special”) {………}
c. Function GetDiscount($Type: = “Special”) {………}
d. Function GetDiscount($Type : “Special”) {………}
Ans: b
Ques: Which of the following are “magic constant”?
a. __LINE__
b. __FILE__
c __PRETTY_FUNCTION__
d __CLASS__
e. __METHOD__
Ans: c
Ques: 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)
Ans: a
Ques: Which one of the following is turnary operator?
a. &
b. =
c. :?
d. ?:
e. +=
f. &&
Ans: D
Ques: What is the result of the following Exprssion?
5+2*4+6
a. 70
b. 19
c. 34
d. 21
Ans: B
Ques: The default value of register global in PHP is:
a. Off
b. On
Ans: A
Ques: What would b the outpur of the following code?
$string = ‘good day’;
$string = ucword($string);
echo $string;
?>
a. good day
b. GOOD DAY
c. Good Day
d. non of the above
Ans: C
Ques: If you want to pass a value to a function by reference, the correct way is:
a. function ModifyReport(&$Rptfile){}
b. function ModifyReport($Rptfile){}
c. function ModifyReport(ByRef $Rptfile){}
d. function ModifyReport(&Rptfile){}
Ans: D

1.Question
Class emp extends person{
funciton GetSal()
{
???
}
}
?>
The getSal() of emp has to behave exactly as getSal() of person .which of the folliwing lines of code would you use to replce the
????
a. perent:: getSal();
b. person:: getSal();
c. parent:: getSal;
d. person:: getSal;
2.Question
what would be the output of the following code?
$stg=’good day’;
$stg= ucwords($stg);
echo $stg;
?>
a. good day
b. GOOD DAY
c. Good Day
d None of the above
3.Question:
which of the following command line interface constant is not defined in the cli sapi?
a. STDIN
b. STDOUT
c. STDPRT
d STDERR
4.Question:
if the session_cache_expire()is not set,then by default the session cache will expire after:
a. 1 hr
b. 2 hr
c. 3 hr
d 4 hr
5.Question:
Which of the following is not a correct way of commenting in php?
a. //php comment
b. /*php comment*/
c. #php comment
d /# php comment
6.Question:
What is true regarding this code?
a. setcookie will return false
b. setcookie will return true
c. setcookie will return null
d. Any of the above can happen
7.Question:
Which of the following is not a correct way of printing text in php5?
a. echo “Plain text”;
?>
b.
c.
d. <# echo “Plain text” #>
8.Question:
Which of the following is not the correct way of starting a session?
a. session.auto_start
b. session_register()
c. session_initiate()
d. session_start()
9.Question:
Which of the following functions do you need to implement HTTP Basic Authentication?
a. authenticate ()
b. header ()
c. basic_auth ()
d. None of the above
10.Question:
Which of the following Command Line Interface constant is not defined in the CLI SAPI?
a. STDIN
b. STDOUT
c. STDPRT
d. STDERR
11.Question:
Which of the following statements is correct with regard to final and abstract?
a. An abstract class cannot have final methods
b. An abstract class cannot have non abstract methods
c. A final class cannot have abstract methods
d. A final class cannot have final methods
12.Question:
Which composite data types are supported by php?
a. Array
b. Enumeration
c. List
d. Object
e. Integer
13.Question:
The default value of register_globals in PHP is:
a. Off
b. On
14.Question:
Which of the following is not a valid PHP connection status?
a. aborted
b. normal
c. open
d. timeout
15.Question:
Choose the correct statement:
a. include() includes and evaluates a specific file
b. require() includes and evaluates a specific file
c. include_once() includes and evaluates a specific file only if it has not been included before
d. require_once() includes and evaluates a specific file only if it has not been included before
e. All of the above
16.Question:
If the session_cache_expire() is not set, then by default the session cache will expire after:
a. 1 hr
b. 2 hrs
c. 3 hrs
d. 4 hrs
17.Question:
$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>
a. It will print 50
b. It will print 51
c. It will print 52
d. It will print 1
18.Question:
State whether True or False
Paamayim Nekudotayim operator allows access only to the static members of a class?
a. True
b. False
19.Question:
Which of the following statements is true with regard to comparisons in PHP5?
a. With “= =” operator, two object instances are equal if they have the same attributes and values, and are instances of a different class.
b. With “==” operator two object instances are equal if they have the same attributes and values, and are instances of the same class.
c. With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
d. With (===) operator, object variables are identical if and only if they refer to the different instance of the same class.
20.Question:
You have to upload a file using form post method:
1
2 Send this file:
3
4
What should be the code in line 3, if the file name to upload is “SalesFile”?
a.
b.
c.
d.
21.Question:
Which of the following built-in function assist in checking if actually the function exists or not?
a. exists
b. function_exists
c. fexists
d. isFunction
22.Question:
What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a =”=””>
a. 0.9
Not Equals
b. 1
Equals
c. 1
Not Equals
d. 1.1
Not Equals
e. None of the above
23.Question:
What will be the output of the following code?
$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;
a. 5 31 6
b. 5 31 6.2
c. 5 31 7
d. 4 31 7.5
e. 5 31 7.5
24.Question:
Which of the following is a not a correct way of commenting in php?
a. //PHP Comment
b. /*PHP Comment*/
c. #PHP Comment
d. /#PHP Comment
25.Question:
Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?
a. 16
b. 18
c. 19
d. 20
e. 17
Ans 18;
26.Question:
Which of the following is the correct way of specifying default value?
a. function GetDiscount($Type = “Special”) { . . . }
b. function GetDiscount(Type := “Special”) { . . . }
c. function GetDiscount($Type := “Special”) { . . . }
d. function GetDiscount($Type : “Special”) { . . . }
27.Question:
With reference to the following php script:
print ‘Text Line1?
print ‘Text Line2?
?>
What will be the output on running the script?
a. Text Line1Text Line2
b. Text Line1 Text Line2
c. ‘Text Line1?
d. ‘Text Line2?
e. Error message will be printed
28.Question:
What will be the ouput of the following code?
for ($i = 0; $i < i =”=””>
a. 0
1
2
3
4
5
b. 0
1
3
4
c. 2
d. 0
1
2
4
e. None of the above
29.Question:
Late PHP versions support remote file accessing for the functions:
a. include()
b. include_once()
c. require_once()
d. Both a and b
e. Both b and c
Question:
You have designed a user login form as follows:
User Name:
Password:
How can you access the username entered by the user in the ‘Validate.php’ webpage?
a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables(‘p’, ‘p_’);
$var= $p_username;
d. All of the above
30.Question:
Which of the following does not represent logical AND operator in PHP?
a. &
b. &&
c. And
d. AND
Question:
Which of the following is not true for a persistent connection?
a. These are not closed even after the execution of the script
b. These are mainly used to increase the efficiency of the system
c. These can’t be converted to non-persistent connections
d. These are preferably not used in the scripts involving transactions
31.Question:
Which of the following are invalid data types in PHP?
a. string
b. integer
c. float
d. char
e. array
f. object
32.Question:
The Manager and Office classes are as follows:
class Manager{
function printName() {
echo “Manager”;
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>
Which of the following should replace ‘???’ to obtain the value of printName() function?
a. $ofc->getManager()->printName();
b. new Office()->getManager()->printName();
c. $ofc->getManager->printName;
d. Office::getManager()::printName();
33.Question:
The classes are defined as follows:
abstract class BaseCls{
protected abstract function getName();
}
class ChildCls extends BaseCls{
}
Which of the following implementations of getName() is invalid in ChildCls?
a. protected function getName(){}
b. function getName(){}
c. private function getName(){}
d. public function getName(){}
34.Question:
Which of the following variable declarations within a class is invalid in PHP5?
a. private $type = ‘moderate’;
b. var $term =3;
c. public $amnt = ’500?;
d. protected $name = ‘Quantas Private Limited’;
35.Question:
What will be the output of following code?
$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];
a. ab
b. $arr is undefined
c. bb
d. Parse error
36.Question:
For the following code:
the output will be:
a. 171
b. Expressions can’t be used with echo statements
c. 150.7
d. 30 * 5.7
37.Question:
What is the result of the following expression?
5+2 * 4+6
a. 70
b. 19
c. 34
d. 21
38.Question:
What will be the output of following code?
$var = 1 + “-1.3e3?;
echo $var;
a. -1299
b. 1
c. 1-1.3e3
d. Error:cannot add integer and string
39.Question:
What will be the output of following code?
$var1=”a”;
$$var1=”b”;
echo “$var1 $a”;
a. a b
b. $var1 $a
c. Error: $a is undefined
d. Error: Parse error in line 2 ($$var1 = “b”)
40.Question:
What is the output of the following code?
$a = 500;
$b = 200;
echo $a % 2
* $b;
?>
a. 100
b. 200
c. 500
d. 0
e. Syntax error
41.Question:
What will be the ouput of the following code?
if (-1)
print “true”;
else
print “false”;
?>
a. true
b. false
42.Question:
What will be the output of the following code?
echo 12 . 6;
a. 12 . 6
b. 126
c. 12.6
d. Error: You cannot add integers through the concatenation operator(.)
43.Question:
Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;
What will be the value of $z?
a. 0
b. 1
c. 2
d. 3
e. 4
44.Question
The setrawcookie() method of setting cookies is different from PHP standard method of cookie setting as:
a. It does not allow expiry time to be set
b. It can be used only once
c. It does not URL-ENCODE the value on its own
d.It does not allow domain setting
45.Question
You need to keep an eye on the existing number of objects of a given class without introducing a non-class varibale. which of the following makes this happen?
a. Add a member varibale that gets incremented in the default constructer and decremented the destructer.
b. Add a local variable that gets incremented in each constructer and decremented in the desructer
c. Add a static member variable that gets incremented in each constructer and decreented in the destructor
d. This cannot be accomplished since the creation of objects is being done dynamically via “new”
46.Question
How can you hide the fact that web pages are written in PHP?
a. By using AddType application/X-httpd-php asp
b. Specify all file names without any dot and extension
c. By using .htaccess diretive in Apeche
d. All of the above
46.Question
What is the output of the following code?
$a = 3;
$b = 2;
echo (int)$a/(int)$b
?>
a. 1
b. 1.5
c. 2
d. 3
e. Error
47.Question
Which one is correct?
a. $s = fwrite (“a string here”);
b. $s = fwrite ($fp,”a string here”);
c. $s = fwrite (“a string here”,$fp);
d. non of the above
48.Question
Which of the following set of operations is not valid in PHP 5?
a. >, >=
b. =,==
c. !==,!==
d. +=, *=
49.Question
Late PHP version support remote file accessing for the functions:
a. include()
b. include_once()
c. require_once()
d. All of the above
PHP Test And solutions
50.Question.
which of the following are used for code reuse?
a. Loops
b. functions
c. Database
d. include files
51.Question
Which of the following are ”magic constant’?
a. __LINE__
b. __FILE__
c __PRETTY_FUNCTION__
d __CLASS__
e. __METHOD__
52.Question
Which one of the following is turnary operator?
a. &
b. =
c.
d. ?:
e. +=
f. &&
53.Question
What is the result of the following Exprssion?
5+2*4+6
a. 70
b. 19
c. 34
d. 21
54.Question.
The default value of register global in PHP is:
a. Off
b. On
55.Question
What would b the outpur of the following code?
$string = ‘good day’;
$string = ucword($string);
echo $string;
?>
a. good day
b. GOOD DAY
c. Good Day
d. non of the above
56.Question
If you want to pass a value to a function by reference, the correct way is:
a. function ModifyReport(&$Rptfile){}
b. function ModifyReport($Rptfile){}
c. function ModifyReport(ByRef $Rptfile){}
d. function ModifyReport(&Rptfile){}


1.Question:

What is true regarding this code?
a. setcookie will return false
b. setcookie will return true
c. setcookie will return null
d. Any of the above can happen

Answer: b

2.Question:
Which of the following is not a correct way of printing text in php5?

a. echo "Plain text";
?>
b.
c.
d. <# echo "Plain text" #>

Answer: a

3.Question:
Which of the following is not the correct way of starting a session?
a. session.auto_start
b. session_register()
c. session_initiate()
d. session_start()

Answer: c

4.Question:
Which of the following functions do you need to implement HTTP Basic Authentication?
a. authenticate ()
b. header ()
c. basic_auth ()
d. None of the above

Answer: d

5.Question:
Which of the following Command Line Interface constant is not defined in the CLI SAPI?

a. STDIN
b. STDOUT
c. STDPRT
d. STDERR

Answer: c

6.Question:
Which of the following statements is correct with regard to final and abstract?

a. An abstract class cannot have final methods
b. An abstract class cannot have non abstract methods
c. A final class cannot have abstract methods
d. A final class cannot have final methods

Answer: b

7.Question:
Which composite data types are supported by php?

a. Array
b. Enumeration
c. List
d. Object
e. Integer

Answer: a

8.Question:
The default value of register_globals in PHP is:

a. Off
b. On

Answer: a

9.Question:
Which of the following is not a valid PHP connection status?
a. aborted
b. normal
c. open
d. timeout

Answer: c

10.Question:
Choose the correct statement:
a. include() includes and evaluates a specific file
b. require() includes and evaluates a specific file
c. include_once() includes and evaluates a specific file only if it has not been included before
d. require_once() includes and evaluates a specific file only if it has not been included before
e. All of the above

Answer: e

11.Question:
If the session_cache_expire() is not set, then by default the session cache will expire after:
a. 1 hr
b. 2 hrs
c. 3 hrs
d. 4 hrs

Answer: 3

12.Question:
What will be the output of the following script?$count=50;
function Argument()
{
$count++;
echo $count;
}
Argument();
?>


a. It will print 50
b. It will print 51
c. It will print 52
d. It will print 1

Answer: 1

13.Question:
State whether True or False

Paamayim Nekudotayim operator allows access only to the static members of a class?

a. True
b. False

Answer: a

14.Question:
Which of the following statements is true with regard to comparisons in PHP5?

a. With "= =" operator, two object instances are equal if they have the same attributes and values, and are instances of a different class.
b. With "==" operator two object instances are equal if they have the same attributes and values, and are instances of the same class.
c. With (===) operator, object variables are identical if and only if they refer to the same instance of the same class.
d. With (===) operator, object variables are identical if and only if they refer to the different instance of the same class.

Answer: c

15.Question:
You have to upload a file using form post method:
1
2 Send this file:
3
4

What should be the code in line 3, if the file name to upload is "SalesFile"?


a.
b.
c.
d.

Answer: a

16.Question:
Which of the following built-in function assist in checking if actually the function exists or not?
a. exists
b. function_exists
c. fexists
d. isFunction

Answer: b

17.Question:
What will be the output of the following code?
$a = 0.0;

for ($i = 0; $i < a ="="">


a. 0.9
Not Equals
b. 1
Equals
c. 1
Not Equals
d. 1.1
Not Equals
e. None of the above

Answer: c

18.Question:
What will be the output of the following code?$i=4;
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . " " . $j . " " . $k . " ";


a. 5 31 6
b. 5 31 6.2
c. 5 31 7
d. 4 31 7.5
e. 5 31 7.5

Answer: e

19.Question:
Which of the following is a not a correct way of commenting in php?

a. //PHP Comment
b. /*PHP Comment*/
c. #PHP Comment
d. /#PHP Comment

Answer: d

20.Question:
Following is a php code block:
$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;

what will be the output?


a. 16
b. 18
c. 19
d. 20
e. 17

Answer: 18                      
Posted by odesk test answe

21.Question:
Which of the following is the correct way of specifying default value?

a. function GetDiscount($Type = "Special") { . . . }
b. function GetDiscount(Type := "Special") { . . . }
c. function GetDiscount($Type := "Special") { . . . }
d. function GetDiscount($Type : "Special") { . . . }

Answre: a

22.Question:
With reference to the following php script:
print 'Text Line1'
print 'Text Line2'
?>

What will be the output on running the script?


a. Text Line1Text Line2
b. Text Line1 Text Line2
c. 'Text Line1'
d. 'Text Line2'
e. Error message will be printed
Answer: e

23.Question:
What will be the ouput of the following code?

for ($i = 0; $i < i ="="">


a. 0 1 2 3 4 5

b. 0 1 3 4

c. 2

d. 0 1 2 4

e. None of the above


Answer: b

24.Question:
Late PHP versions support remote file accessing for the functions:

a. include()
b. include_once()
c. require_once()
d. Both a and b
e. Both b and c


Answer: e

25.Question:
You have designed a user login form as follows:

User Name:

Password:

How can you access the username entered by the user in the 'Validate.php' webpage?


a. $var= $_POST['username'];
b. $var= $_REQUEST['username'];
c. import_request_variables('p', 'p_');
$var= $p_username;
d. All of the above

Answer: d

26.Question:
Which of the following does not represent logical AND operator in PHP?

a. &
b. &&
c. And
d. AND

Answer: a

27.Question:
Which of the following is not true for a persistent connection?
a. These are not closed even after the execution of the script
b. These are mainly used to increase the efficiency of the system
c. These can't be converted to non-persistent connections
d. These are preferably not used in the scripts involving transactions

Answer: c

28.Question:
Which of the following are invalid data types in PHP?


a. string
b. integer
c. float
d. char
e. array
f. object

Answer: d

29.Question:
The Manager and Office classes are as follows:class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}

$ofc = new Office();
???

?>

Which of the following should replace '???' to obtain the value of printName() function?


a. $ofc->getManager()->printName();
b. new Office()->getManager()->printName();
c. $ofc->getManager->printName;
d. Office::getManager()::printName();

Answer: a

30.Question:
The classes are defined as follows:abstract class BaseCls{
protected abstract function getName();
}

class ChildCls extends BaseCls{

}

Which of the following implementations of getName() is invalid in ChildCls?


a. protected function getName(){}
b. function getName(){}
c. private function getName(){}
d. public function getName(){}

Answer d

31.Question:
Which of the following variable declarations within a class is invalid in PHP5?

a. private $type = 'moderate';
b. var $term =3;
c. public $amnt = '500';
d. protected $name = 'Quantas Private Limited';

Answer: b

32.Question:
What will be the output of following code?
$arr = "a";
$arr[0]="b";
echo $arr;
echo $arr[0];


a. ab
b. $arr is undefined
c. bb
d. Parse error

Answer: c                        
Posted by odesk test answer                 
33.Question:
For the following code:

the output will be:


a. 171
b. Expressions can't be used with echo statements
c. 150.7
d. 30 * 5.7

Answer: a

34.Question:
What is the result of the following expression?5+2 * 4+6

a. 70
b. 19
c. 34
d. 21

Answer: b

35.Question:
What will be the output of following code?$var = 1 + "-1.3e3";
echo $var;


a. -1299
b. 1
c. 1-1.3e3
d. Error:cannot add integer and string

Answer: a

36.Question:
What will be the output of following code?
$var1="a";
$$var1="b";
echo "$var1 $a";


a. a b
b. $var1 $a
c. Error: $a is undefined
d. Error: Parse error in line 2 ($$var1 = "b")

Answer: a

37.Question:
What is the output of the following code?
$a = 500;
$b = 200;

echo $a % 2
* $b;
?>


a. 100
b. 200
c. 500
d. 0
e. Syntax error


Answer: d

38.Question:
What will be the ouput of the following code?

if (-1)
print "true";
else
print "false";
?>


a. true
b. false

Answer: a

39.Question:
What will be the output of the following code?
echo 12 . 6;


a. 12 . 6
b. 126
c. 12.6
d. Error: You cannot add integers through the concatenation operator(.)

Answer: b

40.Question:
Consider the following sample code:
$x = 0xFFFE;
$y = 2;
$z = $x && $y;

What will be the value of $z?


a. 0
b. 1
c. 2
d. 3
e. 4

Answer: b

Comments

Popular posts from this blog

Freelancer Wordpress Exam Answers 2016

100 percent Rank your website on Google for $13