Skip to main content

Module php_eval

Module php_eval 

Source
Expand description

Execute embedded PHP code within a running PHP extension.

This module provides a way to compile and execute PHP code that has been embedded into the extension binary at compile time using include_bytes!.

Uses zend_compile_string + zend_execute (not zend_eval_string) to avoid security scanner false positives and compatibility issues with hardened PHP configurations.

§Example

use ext_php_rs::php_eval;

// Both include_bytes! and include_str! are supported:
const SETUP_BYTES: &[u8] = include_bytes!("../php/setup.php");
const SETUP_STR: &str = include_str!("../php/setup.php");

php_eval::execute(SETUP_BYTES).expect("failed to execute embedded PHP");
php_eval::execute(SETUP_STR).expect("failed to execute embedded PHP");

Enums§

PhpEvalError
Errors that can occur when executing embedded PHP code.

Functions§

execute
Execute embedded PHP code within the running PHP engine.