Time: 20 minutes
Question .No: 18
Allowed: pencil + a piece of paper

1. What will the following PHP script display?
function get_sum(){
global $var;
$var = 5;
 $var = 10;
 echo $var;
A. 15
C. 5
D. 10
 The same question if ignoring the line global $var; 
2. Which of the following structures are not supported in PHP5? (more than one can be selected)
A. Multiple inheritance
B. Abstract classes
C. Interfaces
D. Public and private method
3. Is it true that functions in PHP cannot be overloaded or redefined?
A. Yes
B. No
4. How could the expression in “echo” below is fixed?
$arr[‘one’] = 14;
echo “Event happended $arr[‘one’] days ago”;
A. ” .$arr[‘one’]. “
B. $arr{one}
C. {$arr[‘one’]}
5. What does the following PHP script do? (more than one can be selected)
$id = 3;
$str = “active$id”;
$$str = 1;
A. Sets the variable $str to 1
B. Declares $active3 as a new variable
C. Sets the variable $str to “active3”
D. Nothing. The script is invalid
6. How many parameters can the following function accept?
function get_sum()
A. 0
B. 1
C. Any number
7. What is “herodoc” used for?
A. Creating multi-line strings with quotation marks
B. Creating single-line strings with quotation marks
C. Creating multi-line strings without quotation marks
D. Creating single-line strings without quotation marks
8. Can “echo” accept more than 1 parameter?
A. No
B. Yes
9. What is “<<<” operator used for?
A. To declare a regular expression
B. It is similar to “echo”
C. To declare a string variable
10. What will the following PHP script display?
abstract class Foo 
abstract function bar(array $params=NULL); 
class Moo extends Foo
public function bar(array $params)
echo count($params);
$c = new Moo();
A. 1
B. 5
C. 0
D. Fatal error
11. How do you start a PHP session?
A. Using session_start()
B. Using session_set()
C. Using session_register()
D. Using the variable $_SESSION
12. Which of the following statements about abstract classes are true?  (more than one can be selected)
A. It is necessary to instantiate at least one object of an abstract class
B. Methods declared as abstract define only their signature and cannot contain any functionality
C. Methods declared as abstract contain functionality which cannot be overridden by the classes which inherit them
D. It is not possible to instantiate an object of an abstract class
13. What will the following PHP script display?
$str = 123;
echo “Value of variable – $str”; 
A. Value of variable – $str
B. Value of variable – 123
C. Value of variable – $str
The same question with:
echo “Value of variable – $str”; 
echo ‘Value of variable – $str’;
echo ‘Value of variable – $str’; 
14. Which function returns a list of reponse headers?
A. header_getAll()
B. headers()
C. headers_list()
D. headers_send()
15. What is the following PHP script display?
$number = array(0.57,”21.5″, 40.52);
if (in_array(21.5, $number,true)) echo “The value 21.5 is found”;
else echo “21.5 is not found”;
A. “21.5 is not found”
B. “The value 21.5 is found”
C. Nothing. The script is invalid
16. What is the difference between accessing class methods via “->” and accessing via “::”?
A. “->” is for static methods, “::” is for non-static methods.
B. “->” is for static methods, “::” is for all methods.
C. “->” is for all methods, “::” is for static methods.
D. “->” is for non-static methods, “::” is for static methods.
E. There is no difference.
17. Which change will make the following PHP script display the string “Hello, World!”?
function myfunction()
     print $string;
myfunction(“Hello, World!”);
A.  Replacing ??? with $string = $argv[1];
B. Replacing ??? with $string = get_function_args();
C. Replacing ??? with list($string) = func_get_args();
D. Nothing can be replaced.
18. Which function is best suited for removing markup tags from a string?
A. reg_replace()
B. strip_markup()
C. strip_tags()
D. str_replace()
Answer: 1.C 2.A 3.A 4.A 5.B,C 6.C 7.C 8.B 9.A 10.D 11.A 12.B,D 13.A 14.C 15.A 16.D 17.C 18.C
close slider

    BusinessE-commerce/ Online storeNon-profitPersonal websiteI'm not sureOther

    Create a new websiteOverhaul of my websiteMinor changes to my websiteOther

    Help customer find my business onlineSell my product or service and take payments onlineSell my product or service, taking payments offlineProvide information to the publicOther

    ASAPIn the next few weeksIn the next monthIn the next 2-3 monthsI'm not sureOther

    I'm not sureLess than 1 monthUp to 3 monthsUp to 6 monthsOther

    Pin It on Pinterest