What role does the output_buffering setting in php.ini play in preventing the "headers already sent by" error in PHP?

When PHP sends output to the browser, it also sends HTTP headers. If any content is sent before these headers, it will result in the "headers already sent by" error. One way to prevent this error is by using the output_buffering setting in the php.ini file. This setting allows PHP to buffer output before sending it to the browser, ensuring that headers are sent first before any content.

// Set output_buffering to On in php.ini file
output_buffering = On