Skip to content

Commit

Permalink
PHP Show & Tell Fun
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Oct 3, 2023
1 parent 3ef41ed commit ab0f908
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion esm/interpreter/php-wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ export default {
async engine({ PhpWeb }, _, url) {
const { stderr, stdout, get } = stdio();
const interpreter = await new Promise(resolve => {
let timer = 0, chunks = [];
const php = new PhpWeb({
print: stdout,
print: (message) => {
chunks.push(message);
clearTimeout(timer);
timer = setTimeout(() => {
document.getElementById('target').innerHTML = chunks.splice(0).join('');
});
},
printErr: (message) => {
if (message) stderr(message);
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"html-escaper": "^3.0.3"
},
"worker": {
"blob": "sha256-ixJNXrBnwM18zoc4l44JmnNzgD+eoNpGaOcZz3dXP94="
"blob": "sha256-BDFBL6yh1wOU5tFuRvJ/0Eg3QHPu/yDsay/B77CbrGM="
}
}
4 changes: 2 additions & 2 deletions test/php-wasm.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</head>
<body>
<script type="php-wasm">
echo 'Hello PHP';
vrzno_run('alert', ['Hello, World!']);
phpinfo();
</script>
<div id="target"></div>
</body>
</html>

0 comments on commit ab0f908

Please sign in to comment.