<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>php</title> </head> <body> <textarea rows="10" cols="100" id="code"> <?php echo date('Y-m-d H:i:s'); ?> </textarea> <p><button>run php code</button></p> <script type="text/javascript" src="php.js" async></script> <script type="text/javascript"> document.querySelector('button').addEventListener('click', function(){ function init() { let code = document.getElementById("code").value; code = code.replace(/^\s*<\?php/, ""); code = code + "\necho PHP_EOL;"; let result = phpModule.ccall('pib_eval', 'number', ["string"], [code]); /*值爲0表示成功*/ console.log("run=" + result); } var config = { postRun: [init], print: function(text){ console.log(text); }, printErr: function(text){ console.log(text); } }; var phpModule = PHP(config); }); </script> </body> </html>
能夠去https://xxfaxy.gitee.io/pib/index.html把資源爬下來javascript