pub fn as_str(&self) -> Result<&str> {
        if unsafe { ext_php_rs_is_known_valid_utf8(self.as_ptr()) } {
            let str = unsafe { std::str::from_utf8_unchecked(self.as_bytes()) };
            return Ok(str);
        }
        let str = std::str::from_utf8(self.as_bytes()).map_err(|_| Error::InvalidUtf8)?;
        unsafe { ext_php_rs_set_known_valid_utf8(self.as_ptr().cast_mut()) };
        Ok(str)
    }
Attempts to return a reference to the underlying bytes inside the Zend
string.

# Errors

Returns an [`Error::InvalidUtf8`] variant if the [`str`] contains
non-UTF-8 characters.

# Example

```no_run
use ext_php_rs::types::ZendStr;

let s = ZendStr::new("hello, world!", false);
assert!(s.as_str().is_ok());
```
src/types/string.rs