PHP Basics MCQs
11. Which of the below symbol is a newline character?
A. \r
B. \n
C. /r
D. /n
View Answer
Ans : B
Explanation: PHP treats \n as a newline character.
12. PHP files can contain ________ code.
A. text
B. HTML
C. python
D. Both A and B
View Answer
Ans : D
Explanation: PHP files can contain text, HTML, CSS, JavaScript, and PHP code.
13. which of the following is new operator added in PHP 7?
A. <=!
B. <=$
C. <=>
D. <=?
View Answer
Ans : C
Explanation: PHP 7 supports new operators (like the spaceship operator: <=> )
14. 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)
View Answer
Ans : D
Explanation: 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.
15. PHP can create, open, read, write, delete, and close files on the server.
A. True
B. False
C. PHP can only create, open and close files on the server
D. PHP can read, write and delete files on the server
View Answer
Ans : A
Explanation: PHP can create, open, read, write, delete, and close files on the server.
16. What will be the output of the following PHP code?
<?php
$x = 8;
$y = 8.0;
echo ($x === $y);
?>
A. 8 === 8
B. No Output
C. 1
D. 0
View Answer
Ans : B
Explanation: === operator returns 1 if $x and $y are equivalent and $x and $y have not the same type.So it will give no output.
17. The script that executes at the browser side is called _____
A. Client side scripting
B. Server side scripting
C. Both A and B
D. None of the above
View Answer
Ans : A
Explanation: The script that executes at the browser side is called Client-side scripting.
18. PHP can send and receive cookies?
A. True
B. False
C. PHP older version can not send and receive cookies but new version can.
D. PHP new version can not send and receive cookies but old version can.
View Answer
Ans : A
Explanation: PHP can send and receive cookies.
19. On which Platform PHP Runs?
A. Windows
B. Linux
C. Mac OS X
D. All of the above
View Answer
Ans : D
Explanation: PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
20. The PHP syntax is most similar to:
A. VBScript
B. JavaScript
C. Perl and C
D. All of the above
View Answer
Ans : C
Explanation: The php syntax is most similar to Perl And C.
Discussion