Skip to main content

output_write

Function output_write 

Source
pub fn output_write(data: &[u8]) -> usize
Expand description

Writes binary data to PHP’s output stream with output buffering support.

This function is binary-safe (can handle NUL bytes) AND respects PHP’s output buffering (ob_start()). Use this when you need both binary-safe output and output buffering compatibility.

§Arguments

  • data - The binary data to write.

§Returns

The number of bytes written.

§Comparison

FunctionBinary-safeOutput Buffering
printfNoYes
write()YesNo (unbuffered)
output_writeYesYes

§Example

use ext_php_rs::zend::output_write;

// Binary data that will be captured by ob_start()
let data = b"Hello\x00World";
output_write(data);