PHP Syntax
6. | Which of the following is used to loop through the values of an array in PHP? |
---|
A. for loop
B. while loop
C. foreach loop
D. do-while loop
View Answer Discuss Work SpaceAnswer: option c
Explanation:
foreach loop is used to loop through the values of an array in PHP.
7. | Which of the following is used to define a constant in PHP? |
---|
A. define()
B. const()
C. var()
D. let()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
define() is used to define a constant in PHP.
8. | What is the correct syntax to include a file in PHP? |
---|
A. include "filename";
B. require "filename";
C. include_once "filename";
D. all of the above
View Answer Discuss Work SpaceAnswer: option d
Explanation:
all of the above are correct syntaxes to include a file in PHP.
9. | Which of the following is used to terminate a loop in PHP? |
---|
A. exit
B. continue
C. break
D. return
View Answer Discuss Work SpaceAnswer: option c
Explanation:
break is used to terminate a loop in PHP.
10. | What is the correct syntax to define a function in PHP? |
---|
A. function function_name()
B. function_name()
C. function function_name(parameters)
D. function function_name(parameters)
View Answer Discuss Work SpaceAnswer: option d
Explanation:
function function_name(parameters) is the correct syntax to define a function in PHP.