PHP Unconference Europe 2015

V8Js::registerExtension

(PECL v8js >= 0.1.0)

V8Js::registerExtensionRegister Javascript extensions for V8Js

Descrierea

public static bool V8Js::registerExtension ( string $extension_name , string $script [, array $dependencies = array() [, bool $auto_enable = FALSE ]] )

Registers passed Javascript script as extension to be used in V8Js contexts.

Parametri

extension_name

Name of the extension to be registered.

script

The Javascript code to be registered.

dependencies

Array of extension names the extension to be registered depends on. Any such extension is enabled automatically when this extension is loaded.

Notă:

All extensions, including the dependencies, must be registered before any V8Js are created which use them.

auto_enable

If set to TRUE, the extension will be enabled automatically in all V8Js contexts.

Valorile întoarse

Returns TRUE if extension was registered successfully, FALSE otherwise.

add a note add a note

User Contributed Notes 1 note

up
0
dimarikson at yandex dot ru
15 days ago
Usage sample:

if (V8Js::registerExtension('myjs', 'var x = 1 + 1;', array(), true) === false) {
    exit("Failed to register js extension script");
}

$v8js = new V8Js;

$jsExec = <<<EOD
x;
EOD;

echo $v8js->executeString($jsExec)."\n";    // print "2"
To Top