I ran js in php and went to the zend website this day. I saw a monkeyspider tag,
Http://devzone.zend.com/article/4704-Using-JavaScript-in-PHP-with-PECL-and-SpiderMonkey
Hey, I used to write an extension php extension in c to link spiderMonkey with php. I tried it and ran it. I 'd like to share it with you.
First, download
Http://ftp.mozilla.org/pub/mozilla.org/js/ js-1.7
Http://pecl.php.net/package/spidermonkey spidermonkey php extension
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# ldconfig
Go to the spidermonkey and php extension directory,
shell# phpizeshell# ./configureshell# makeshell# make install
Errors may be reported during make. comment the lines that are reported with errors. use the attributes not found in php struct to open the extension in php. ini.
Code
Assign ('A', $ a); $ js-> assign ('B', $ B ); // define script code $ script = <END c = a + B; END; // evaluate script and display result echo "The sum of $ a and $ B is: ". $ js-> evaluateScript ($ script);?>