pub fn write(data: &[u8]) -> Result<usize>Expand description
Writes binary data to PHP’s output stream (stdout).
Unlike printf, this function is binary-safe and can handle data
containing NUL bytes. It uses the SAPI module’s ub_write function
which accepts a pointer and length, allowing arbitrary binary data.
Also see the php_write! macro.
§Arguments
data- The binary data to write to stdout.
§Returns
The number of bytes written.
§Errors
Returns crate::error::Error::SapiWriteUnavailable if the SAPI’s ub_write function
is not available.
§Example
ⓘ
use ext_php_rs::zend::write;
// Write binary data including NUL bytes
let data = b"Hello\x00World";
write(data).expect("Failed to write data");