macro_rules! php_write {
($data: expr) => { ... };
}Expand description
Writes binary data to the PHP standard output.
Unlike php_print!, this macro is binary-safe and can handle data
containing NUL bytes. It uses the SAPI module’s ub_write function.
§Arguments
$data- A byte slice (&[u8]) or byte literal (b"...") to write.
§Returns
A Result<usize> containing the number of bytes written.
§Errors
Returns Error::SapiWriteUnavailable if the SAPI’s ub_write function
is not available.
§Examples
ⓘ
use ext_php_rs::php_write;
// Write a byte literal
php_write!(b"Hello World").expect("write failed");
// Write binary data with NUL bytes (would panic with php_print!)
php_write!(b"Hello\x00World").expect("write failed");
// Write a byte slice
let data: &[u8] = &[0x48, 0x65, 0x6c, 0x6c, 0x6f];
php_write!(data).expect("write failed");