企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
该扩展将谷歌的[V8 Javascript Engine](http://code.google.com/p/v8/)嵌入到PHP中。 不支持windows * [范例](https://www.php.net/manual/zh/v8js.examples.php) * [V8Js](https://www.php.net/manual/zh/class.v8js.php)— The V8Js class * [V8Js::\_\_construct](https://www.php.net/manual/zh/v8js.construct.php)— 构造一个新的V8Js对象 * [V8Js::executeString](https://www.php.net/manual/zh/v8js.executestring.php)— 将字符串作为Javascript代码执行 * [V8Js::getExtensions](https://www.php.net/manual/zh/v8js.getextensions.php)— 返回一个已注册扩展的数组 * [V8Js::getPendingException](https://www.php.net/manual/zh/v8js.getpendingexception.php)— 返回挂起未捕获的Javascript异常 * [V8Js::registerExtension](https://www.php.net/manual/zh/v8js.registerextension.php)—注册V8Js的Javascript扩展 * [V8JsException](https://www.php.net/manual/zh/class.v8jsexception.php)— V8JsException类 * [V8JsException::getJsFileName](https://www.php.net/manual/zh/v8jsexception.getjsfilename.php)— The getJsFileName purpose * [V8JsException::getJsLineNumber](https://www.php.net/manual/zh/v8jsexception.getjslinenumber.php)— The getJsLineNumber purpose * [V8JsException::getJsSourceLine](https://www.php.net/manual/zh/v8jsexception.getjssourceline.php)— The getJsSourceLine purpose * [V8JsException::getJsTrace](https://www.php.net/manual/zh/v8jsexception.getjstrace.php)— The getJsTrace purpose 例子: ``` $v8 = new V8Js(); /* basic.js */ $JS = <<< EOT len = print('Hello' + ' ' + 'World!' + "\\n"); len; EOT; try { var_dump($v8->executeString($JS, 'basic.js')); } catch (V8JsException $e) { var_dump($e); } ```