pub fn execute(code: impl AsRef<[u8]>) -> Result<(), PhpEvalError>Expand description
Execute embedded PHP code within the running PHP engine.
The code must start with a <?php opening tag (case-insensitive),
optionally preceded by a UTF-8 BOM and/or whitespace. The tag is
stripped before compilation. The C wrapper uses
ZEND_COMPILE_POSITION_AFTER_OPEN_TAG (on PHP 8.2+) so the scanner
starts directly in PHP mode.
Error reporting is suppressed during execution and restored afterward, matching the pattern used by production PHP extensions like Blackfire.
§Arguments
code- Raw PHP source, typically frominclude_bytes!orinclude_str!. Any type implementingAsRef<[u8]>is accepted.
§Errors
Returns PhpEvalError::MissingOpenTag if the code does not start
with <?php. Returns other PhpEvalError variants if compilation
fails, an exception is thrown, or a fatal error occurs.