Multiple choice technology web technology

Which of following function return 1 when output is successful?

  1. echo ( )

  2. print()

  3. both

  4. none

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

print() returns 1 when output is successful, while echo() has no return value. This makes print() useful when you need to check if output succeeded, though echo() is slightly faster for simple output since it doesn't need to return a value.

AI explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) echo() - This option is incorrect because the echo() function does not return a value. It simply outputs the given string or variable to the browser or console.

Option B) print() - This option is correct because the print() function outputs the given string or variable to the browser or console, and returns a value of 1 if the output is successful.

Option C) both - This option is incorrect because only the print() function returns a value of 1 when the output is successful. The echo() function does not return a value.

Option D) none - This option is incorrect because the print() function does return a value of 1 when the output is successful.

Therefore, the correct answer is B) print(). This option is correct because the print() function returns a value of 1 when the output is successful.