Test Series - php

Test Number 3/39

Q: What will be the output of the following PHP code?

    
A. 5 === 5
B. Error
C. 1
D. False
Solution: === operator returns 1 if $a and $b are equivalent and $a and $b have the same type.
Q: Which of the below symbols is a newline character?
A. 
B. 
C. /n
D. /r
Solution: PHP treats 
 as a newline character.
Q: Which of the conditional statements is/are supported by PHP?

i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements
A. Only i)
B. i), ii) and iv)
C. ii), iii) and iv)
D. i), ii), iii) and iv)
Solution: All are conditional statements supported by PHP as all are used to evaluate different conditions during a program and take decisions based on whether these conditions evaluate to true of false.
Q: What will be the output of the following PHP code?

    
A. I love arsenal
B. Error
C. I love arsenalI love manc
D. I love arsenalI love mancI love manu
Solution: If a break statement isn’t present, all subsequent case blocks will execute until a break statement is located.
Q: Which of the looping statements is/are supported by PHP?

i) for loop
ii) while loop
iii) do-while loop
iv) foreach loop
A. i) and ii)
B. i), ii) and iii)
C. i), ii), iii) and iv)
D. Only iv)
Solution: All are supported looping statements in PHP as they can repeat the same block of code a given number of times, or until a certain condition is met.
Q: What will be the output of the following PHP code?

    
A. AshleyBale
B. AshleyBaleBlank
C. ShrekBlank
D. Shrek
Solution: The continue statement causes execution of the current loop iteration to end and commence at the beginning of the next iteration.
Q: If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
A. 12
B. 1
C. Error
D. 5
Solution: ?: is known as ternary operator. If condition is true then the part just after the ? is executed else the part after : .
Q: What will be the value of $a and $b after the function call in the following PHP code?

    
A. a is 3 and b is 4
B. a is 4 and b is 3
C. Both are 3
D. Both are 4
Solution: $a is 4 and $b is 3. The former because $arg is passed by reference, the latter because the return value of the function is a copy of the initial value of the argument.
Q: Who is the father of PHP?
A. Rasmus Lerdorf
B. Willam Makepiece
C. Drek Kolkevi
D. List Barely
Solution: PHP was originally created by Rasmus Lerdorf in 1994.

You Have Score    /9