The code can be directly run in your browser, meaning you can execute php code straight out of your browser! It can also be run on node.js, but strongly recommend not to, due to potential security issues.
- Magic methods (2, 3)
- Lamba functions
- Engine execution orders (2,3)
- foreach with references
var engine = new PHP ('<?php echo "Hello world!"; ?>', options); console.log(engine.vm.OUTPUT_BUFFER); // the outputted buffer from the script
The code is by default run synchronously so the output will be immidiately readable upon the engine finishing execution. Alternatively, the VM can be set to run under a web worker as well, in which case a callback function will need to be provided.
The current status of the passing tests can be seen here. I'll be the first admit that there are still a lot of bugs, but considering the complexity of the language, it is well on its way.
npm install grunt
- Test cases from php-src - The PHP License, version 3.01
- Grammar parser adapted from PHP-Parser - by Nikita Popov