您好,欢迎访问一九零五行业门户网

在php 中运行js

这天去zend网站上逛了逛, 看到一个monkeyspider 的标签,
http://devzone.zend.com/article/4704-using-javascript-in-php-with-pecl-and-spidermonkey
嘿嘿, 原来是用c写了一个扩展php扩展 把spidermonkey和php 联起来了。 照着试了试, 还真跑下来了, 拿上来分享一下。
 首先是下载
http://ftp.mozilla.org/pub/mozilla.org/js/  js-1.7
http://pecl.php.net/package/spidermonkey   spidermonkey 的php扩展
shell# tar -xzvf js-1.70.tar-gz
shell# cd js/src
shell# make -f makefile.ref
shell# mkdir -p /usr/local/include/js/
shell# cp *.{h,tbl} /usr/local/include/js/
shell# cd linux_all_dbg.objshell# cp *.h /usr/local/include/js/ shell# cp js /usr/local/bin/ shell# cp libjs.so /usr/local/lib/shell# ldconfig
进入spidermonkey , php 扩展目录,
shell# phpizeshell# ./configureshell# makeshell# make install
在make 的时候可能会报错, 那报错的那几行注释吧, 用了几个php 的struct 里没有的属性在php.ini 里把这个扩展打开吧, 试试把
代码 assign( ' a ' , $a ); $js -> assign( ' b ' , $b ); // define script code $script = <

其它类似信息

推荐信息