To execute PHP scripts within Node.js web server, we call the exec function.
For instance, we write
const exec = require("child_process").exec;
app.get("/", (req, res) => {
exec("php index.php", (error, stdout, stderr) => {
res.send(stdout);
});
});
to call exec to run index.php with php.
We get the output from the stdout parameter in the callback.