PHP Basics
11. | Which of the following is used to loop through an array in PHP? |
---|
A. for loop
B. foreach loop
C. while loop
D. None of the above
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The foreach loop is used to loop through an array in PHP.
12. | Which of the following is used to redirect a user to a different page in PHP? |
---|
A. header()
B. redirect()
C. location()
D. navigate()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The header() function is used to redirect a user to a different page in PHP.
13. | Which of the following is used to set a cookie in PHP? |
---|
A. setcookie()
B. createcookie()
C. set_cookie()
D. create_cookie()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The setcookie() function is used to set a cookie in PHP.
14. | Which of the following is used to read the value of a cookie in PHP? |
---|
A. $_COOKIE[]
B. $_SESSION[]
C. $_REQUEST[]
D. $_GET[]
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The value of a cookie can be read in PHP using the $_COOKIE[] superglobal.
15. | Which of the following is used to handle errors in PHP? |
---|
A. try-catch blocks
B. if-else statements
C. switch statements
D. none of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
Errors in PHP can be handled using try-catch blocks.