PHP Quiz

PHP Programming Quiz

1. What does PHP stand for?
a) Personal Hypertext Processor
b) Private Home Page
c) PHP: Hypertext Preprocessor
d) Professional Hosting Provider

 

2. Which symbol is used to declare a variable in PHP?
a) @
b) $
c) #
d) %

 

3. How do you write a comment in PHP?
a) <!– comment –>
b) // comment
c) # comment
d) Both b and c

 

4. Which of the following is the correct way to start a PHP block?
a) <php>
b) <?php>
c) <?php
d) <script>

 

5. Which function is used to output text in PHP?
a) echo()
b) write()
c) print()
d) Both a and c

 

6. Which of the following is a correct array declaration in PHP?
a) $arr = array(\”one\”, \”two\”);
b) arr[] = {\”one\”, \”two\”};
c) array = [\”one\”, \”two\”];
d) $arr = [\”one\”, \”two\”]

 

7. Which method is used to send data using forms in a secure way?
a) GET
b) POST
c) FETCH
d) SEND

 

8. Which of the following is used to include one PHP file into another?
a) include
b) require
c) import
d) Both a and b

 

9. What will $x = 5 == ‘5’; evaluate to?
a) true
b) false
c) error
d) null

 

10. How do you define a function in PHP?
a) function myFunction {}
b) function myFunction() {}
c) define function myFunction() {}
d) fn myFunction() {}

 

11. What will the following code output? echo strlen(\”Hello\”);
a) 4
b) 5
c) 6
d) Error

 

12. What is the default file extension for PHP files?
a) .html
b) .ph
c) .php
d) .xml