Web Development With PHP
Web Development With PHP - Important Points
21. | Which of the following is NOT a valid way to concatenate two strings in PHP? |
---|
A. $string1 . $string2
B. $string1 + $string2
C. $string1 .= $string2
D. $string1, $string2
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The + operator is used for arithmetic operations in PHP, not string concatenation. String concatenation is done using the dot (.) operator.
22. | Which PHP function is used to generate a random number? |
---|
A. rand()
B. random()
C. randomize()
D. random_number()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The rand() function is used to generate a random number in PHP.
23. | Which of the following is NOT a valid loop in PHP? |
---|
A. for
B. while
C. do-while
D. repeat-until
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The repeat-until loop is not a valid loop in PHP. Instead, the do-while loop is used.
24. | Which PHP function is used to retrieve the length of a string? |
---|
A. length()
B. size()
C. strlen()
D. count()
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The strlen() function is used to retrieve the length of a string in PHP.
25. | Which of the following is NOT a valid comparison operator in PHP? |
---|
A. ==
B. !=
C. <=>
D. ><
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The >< characters are not a valid comparison operator in PHP. The <=> operator is used to compare two values and return either -1, 0, or 1 depending on the result of the comparison.