Which of following function return 1 when output is successful?
-
echo ( )
-
print ( )
-
both
-
None
print() returns 1 when output is successful, making it usable in expressions. echo() outputs content but returns void (no value). This makes print() unique among PHP output functions in having a return value indicating success.
To answer this question, we need to understand the differences between the echo() and print() functions in PHP.
Option A) echo() - This option is incorrect because the echo() function does not return a value. It simply outputs the provided string or variable to the screen.
Option B) print() - This option is correct because the print() function returns a value of 1 if the output is successful. It also outputs the provided string or variable to the screen.
Option C) Both - This option is incorrect because although both echo() and print() can be used to output values to the screen, only the print() function returns a value of 1 when the output is successful.
Option D) None - This option is incorrect because the print() function returns a value of 1 when the output is successful.
Therefore, the correct answer is B) print().