Web Technology MCQs
Web Technology MCQs
12. Which function is used to repeat execution until a condition becomes false?
A. if
B. for
C. while
D. foreach
Answer: C
13. What does the foreach loop do in PHP?
A. Loops through numbers only
B. Loops through arrays
C. Loops through strings
D. Loops through classes
Answer: B
14. In PHP, a function is defined using which keyword?
A. method
B. def
C. function
D. declare
Answer: C
15. What is the correct syntax to define a function in PHP?
A. function myFunction[] {}
B. def myFunction() {}
C. function myFunction() {}
D. myFunction() = function {}
Answer: C
16. What is call by value in PHP?
A. Original variable is changed
B. A copy of the variable is passed
C. It returns nothing
D. It is used in classes only
Answer: B
17. What is call by reference in PHP?
A. Passes only value
B. Passes address of variable
C. Cannot change original variable
D. None of the above
Answer: B
18. What keyword is used to make a function recursive?
A. recur
B. recursive
C. function calling itself
D. loop
Answer: C
19. What does the PHP strlen() function do?
A. Returns string in reverse
B. Converts to uppercase
C. Returns length of string
D. Splits string
Answer: C
20. Which function is used to replace part of a string?
A. str_replace()
B. replace()
C. substr()
D. str_repeat()
Answer: A
21. Which PHP function is used to format a string?
A. printf()
B. str_format()
C. format()
D. string_format()
Answer: A
22. What does strtoupper("php") return?
A. php
B. PHP
C. Php
D. error
Answer: B
23. Which of the following functions is used to search a string?
A. str_search()
B. strpos()
C. search_str()
D. find()
Answer: B
24. Which PHP function is used to concatenate strings?
A. concat()
B. str_concat()
C. . (dot operator)
D. +
Answer: C
25. What will echo "Hello " . "World"; output?
A. HelloWorld
B. Hello World
C. Hello . World
D. Error
Answer: B