Skip to content

Commit e1851e5

Browse files
authored
Merge pull request #261 from davidcole1340/php-sapi-name
Add helper to get the sapi name
2 parents 4186cc4 + 23dcef8 commit e1851e5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/zend/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ mod ini_entry_def;
1111
mod module;
1212
mod try_catch;
1313

14-
use crate::{error::Result, ffi::php_printf};
14+
use crate::{
15+
error::Result,
16+
ffi::{php_printf, sapi_module},
17+
};
1518
use std::ffi::CString;
1619

1720
pub use _type::ZendType;
@@ -51,3 +54,9 @@ pub fn printf(message: &str) -> Result<()> {
5154
};
5255
Ok(())
5356
}
57+
58+
/// Get the name of the SAPI module.
59+
pub fn php_sapi_name() -> String {
60+
let c_str = unsafe { std::ffi::CStr::from_ptr(sapi_module.name) };
61+
c_str.to_str().expect("Unable to parse CStr").to_string()
62+
}

0 commit comments

Comments
 (0)