PHP MCQ Questions
PHP MCQ Questions : This section focuses on "Basics" of PHP. These Multiple Choice Questions (mcq) should be practiced to improve the PHP skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. The term PHP is an acronym for PHP:_______________.
A. Hypertext Preprocessor
B. Hypertext multiprocessor
C. Hypertext markup Preprocessor
D. Hypertune Preprocessor
View Answer
Ans : A
Explanation: The term PHP is an acronym for PHP: Hypertext Preprocessor.
2. PHP is a ____________ language?
A. user-side scripting
B. client-side scripting
C. server-side scripting
D. Both B and C
View Answer
Ans : C
Explanation: PHP is a server-side scripting language designed specifically for web development.
3. Who among this is the founder of php language?
A. Tim Berners-Lee
B. Brendan Eich
C. Guido van Rossum
D. Rasmus Lerdorf
View Answer
Ans : D
Explanation: PHP as it is known today is actually the successor to a product named PHP/FI. Created by Rasmus Lerdorf
4. In which year php was created?
A. 1993
B. 1994
C. 1995
D. 1996
View Answer
Ans : B
Explanation: PHP, as it is known today, is actually the successor to a product named PHP/FI. Created in 1994.
5. PHP files have a default file extension of_______.
A. .html
B. .xml
C. .php
D. .hphp
View Answer
Ans : C
Explanation: To run a PHP file on the server, it should be saved as lfc.php
6. Which of the following is the correct syntax of php?
A. <?php >
B. <php >
C. ?php ?
D. <?php ?>
View Answer
Ans : D
Explanation: Each block of PHP code begins and ends by turning the PHP tag on and off to tell the server that it needs to execute PHP in between.
7. Which of the following is the latest version of php?
A. 7.1
B. 7.2
C. 7.3
D. 7.4
View Answer
Ans : B
Explanation: Latest Version of PHP is 7.2 .
8. Which of the following is the Release date of latest version (7.2) of php?
A. 27 November 2017.
B. 28 November 2017.
C. 29 November 2017.
D. 30 November 2017.
View Answer
Ans : D
Explanation: The Latest Version of PHP is 7.2 and the Release date is 30 November 2017.
9. Which of the below statements is equivalent to $sub -= $sub?
A. $sub = $sub
B. $sub = $sub -$sub
C. $sub = $sub - 1
D. $sub = $sub - $sub - 1
View Answer
Ans : B
Explanation: a -= b is an subtraction assignment whose outcome is a = a - b.
Same can be done with addition, multiplication, division etc.
10. Which statement will output $lfc on the screen?
A. echo "$lfc";
B. echo "$$lfc";
C. echo "/$lfc";
D. echo "$lfc;";
View Answer
Ans : A
Explanation: A backslash is used so that the dollar sign is treated as a normal string character rather than prompt PHP to treat $lfc as a variable.
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.
Also check :
Discussion