Web Development With PHP
Web Development With PHP - Important Points
16. | Which of the following is NOT a valid way to declare a variable in PHP? |
---|
A. $variable = "value";
B. var $variable = "value";
C. $variable = array("value1", "value2");
D. $variable = 123;
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The var keyword is not used to declare variables in PHP. Instead, variables are declared using a $ followed by the variable name.
17. | Which PHP function is used to get the current date and time? |
---|
A. time()
B. date()
C. datetime()
D. now()
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The date() function is used to get the current date and time in PHP.
18. | Which of the following is NOT a valid way to access an element in an array in PHP? |
---|
A. $array[0]
B. $array{"key"}
C. $array["key"]
D. $array->key
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The -> operator is used to access object properties in PHP, not array elements. Array elements are accessed using square brackets [].
19. | Which PHP function is used to encode data in JSON format? |
---|
A. json_encode()
B. encode_json()
C. json()
D. json_format()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The json_encode() function is used to encode data in JSON format in PHP.
20. | Which PHP function is used to convert a string to all uppercase letters? |
---|
A. to_uppercase()
B. strtoupper()
C. upper()
D. case_upper()
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The strtoupper() function is used to convert a string to all uppercase letters in PHP.