dm/runtime

此包已废弃且不再维护。未建议替代包。
此包最新版本(1.0.0)没有可用的许可信息。

PHP库,用于实时禁用和覆盖标准函数

1.0.0 2013-11-07 19:47 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:27:10 UTC


README

现在,您可以在实时中禁用和覆盖标准函数。

<?php
$code = <<<CODE
<?php
echo str_replace( 0, 1, 100 );
?>
CODE;

// thrown exception, becouse str_replace disabled
Dm\Runtime\Api::code($code)
    ->disableFunction('str_replace')
    ->execute();
<?php
$code = <<<CODE
<?php
echo str_replace( 0, 1, 100 );
?>
CODE;

// output 111
echo str_replace( 0, 1, 100 );

// output 000
Dm\Runtime\Api::code($code)
    ->overrideFunction('str_replace', function ($search, $replace, $subject) {
        echo str_replace($replace, $search, $subject);
    })
    ->execute();