PHP Syntax
1. | Which of the following is used to concatenate two strings in PHP? |
---|
A. .
B. +
C. -
D. *
View Answer Discuss Work SpaceAnswer: option a
Explanation:
. is used to concatenate two strings in PHP.
2. | What is the correct syntax to declare a variable in PHP? |
---|
A. $variable_name;
B. var variable_name;
C. $variable_name =;
D. variable_name;
View Answer Discuss Work SpaceAnswer: option a
Explanation:
$variable_name; is the correct syntax to declare a variable in PHP.
3. | Which of the following is used to compare two values for equality in PHP? |
---|
A. ==
B. =
C. ===
D. !=
View Answer Discuss Work SpaceAnswer: option a
Explanation:
== is used to compare two values for equality in PHP.
4. | What is the correct syntax to create an array in PHP? |
---|
A. $array = [1, 2, 3];
B. $array = array(1, 2, 3);
C. $array = {1, 2, 3};
D. $array = (1, 2, 3);
View Answer Discuss Work SpaceAnswer: option b
Explanation:
$array = array(1, 2, 3); is the correct syntax to create an array in PHP.
5. | What is the correct syntax to access an element in an array in PHP? |
---|
A. $array[element];
B. $array[element]
C. array[element];
D. array[element]
View Answer Discuss Work SpaceAnswer: option b
Explanation:
$array[element] is the correct syntax to access an element in an array in PHP.