Top Navigation

Odesk PHP5 Test Questions

PHP5 Test

Test Syllabus

  • Advanced Concepts
  • Operators and Functions
  • Language Syntax
  • Fundamentals
  • Variables and Datatypes
  • New Concepts in PHP5
  • Forms
 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:
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:
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 is not a valid PHP parser tag?
a. script
b. ?p
c. %
d. ?php
 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 is a PHP resource?
a. Domxml document
b. Odbc link
c. File
d. All of the above
Question:
Does PHP 5 support exceptions?
a. Yes
b. No
Question:
What do you infer from the following code?<?php$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 variables are supported by ‘str_replace()’ function?
a. Integer
b. String
c. Boolean
d. Array
Question:
Which of the following attribute is needed for file upload via form?
a. enctype=”multipart/form-data”
b. enctype=”singlepart/data”
c. enctype=”file”
d. enctype=”form-data/file”
Question:
Consider the following two statements:I        while (expr) statementII        while (expr): statement … endwhile;

Which of the following are true in context of the given statements?

a. I is correct and II is wrong
b. I is wrong and II is correct
c. Both I & II are wrong
d. Both I & II are correct
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:
If visibility is not defined for a method/member then it is treated as public static.
a. True
b. False
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. None of the above
 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:
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 crypto in PHP returns longest hash value?
a. md5()
b. sha1()
c. crc32()
d. All return same length hash
 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:
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 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 not supported in PHP5?
a. Type Hinting
b. Reflection
c. Magic Methods
d. Multiple Inheritance
e. Object Cloning
 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:
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:
How would you start a session?
a. session(start);
b. session();
c. session_start();
d. begin_sesion();
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 variable names are invalid?
a. $var_1
b. $var1
c. $var-1
d. $var/1
e. $v1
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:
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:
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 . “<br>”;

}

}

}

DisplayArray($array);

d. function DisplayArray($array) {foreach ($array as $value) {if (is_array($value)) {

DisplayArray($value);

} else {

echo $value . “<br>”;

}

}

}

DisplayArray($array);

Question:
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 interfaces
c. An interface can extend multiple interfaces
d. Methods with same name, arguments, and sequence can exist in the different interfaces implemented by a class
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:
Variable/functions in PHP don’t work directly with:
a. echo()
b. isset()
c. print()
d. All of 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:
Which of the the following are PHP file upload related functions?
a. upload_file()
b. is_uploaded_file()
c. move_uploaded_file()
d. None of the above
 Question:
You wrote following script to check for the right category:1        <?php2        $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:
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 b, c and d
g. All 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:
Which of the following pair have non-associative equal precedence?
a. +, -
b. ==, !=
c. <<, >>
d. &=, |=
 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:
Which of the following functions output text?
a. echo()
b. print()
c. println()
d. display()

,

No comments yet.

Leave a Reply

Powered by WordPress. Designed by Woo Themes