This day went to the Zend website to stroll around, see a monkeyspider label,
Http://devzone.zend.com/article/4704-Using-JavaScript-in-PHP-with-PECL-and-SpiderMonkey
Hey, the original was written in C with an extension PHP extension to SpiderMonkey and PHP linked up. Follow the test, and really ran down, take up to share.
The first is to download
http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7
PHP Extensions for Http://pecl.php.net/package/spidermonkey SpiderMonkey
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. OBJ shell# CP *.h/usr/local/include/js/shell# CP js/usr/local/bin/shell# CP libjs.so/usr/local/lib/shell# LDCO Nfig
Enter SpiderMonkey, PHP extension directory,
shell# phpizeshell#./configureshell# makeshell# Make Install
Make in the time may be error, the error of the lines of comments, with a few php in the struct does not have the attributes in the php.ini to open this extension, try to
Code
Assign (' A ', $a); $js-Assign (' B ', $b);// Define script code $script = <<< EN D C = a + b; END; evaluate script and display result echo "The sum of $a and $b is : " . Evaluatescript, $js ($script);?>