Running JS in PHP

Source: Internet
Author: User
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);?>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.