就像apache、nginx一样,感觉node解释其他语言没什么压力吧。
child_process.exec(command, [options], callback)
比如 var child = require(‘child_process’); child.exec(’/usr/local/php/bin/php test.php’,function(error, stdout, stderr){
});
又来一个, 这次主页模仿 Node 的程度真是服了
React is a platform built on PHP for easily building fast, scalable network applications. React uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
我猜测不管是php采用node的写法, 还是node上能跑php, 都会做成不伦不类的.
如果想写php那么整个php环境就好了. 如果喜欢node, 整个node环境就好了.
似乎现在还没有看到什么杂交的语言甚至是低度流行的.
杂交语言这块, microsoft做了不少, 比如让python支持.net的ironpython(其实也不算杂交了, 因为.net本身其实和语言无关的啦)
直接上 code 吧
const cprocess = require('child_process');
const path = require('path');
const fs = require('fs');
var fpath = path.resolve(__dirname, 'date.php');
fs.chmod(fpath, "775", (err)=>{
if(err){
return console.log(err);
}
cprocess.exec(`php ${fpath}`, (err, stdout, stderr)=>{
if(err){
throw err;
}
console.log(stdout);
console.log(stderr);
})
})