Skip to content

Commit ab0f908

Browse files
committed
PHP Show & Tell Fun
1 parent 3ef41ed commit ab0f908

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Diff for: esm/interpreter/php-wasm.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ export default {
1313
async engine({ PhpWeb }, _, url) {
1414
const { stderr, stdout, get } = stdio();
1515
const interpreter = await new Promise(resolve => {
16+
let timer = 0, chunks = [];
1617
const php = new PhpWeb({
17-
print: stdout,
18+
print: (message) => {
19+
chunks.push(message);
20+
clearTimeout(timer);
21+
timer = setTimeout(() => {
22+
document.getElementById('target').innerHTML = chunks.splice(0).join('');
23+
});
24+
},
1825
printErr: (message) => {
1926
if (message) stderr(message);
2027
},

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@
7171
"html-escaper": "^3.0.3"
7272
},
7373
"worker": {
74-
"blob": "sha256-ixJNXrBnwM18zoc4l44JmnNzgD+eoNpGaOcZz3dXP94="
74+
"blob": "sha256-BDFBL6yh1wOU5tFuRvJ/0Eg3QHPu/yDsay/B77CbrGM="
7575
}
7676
}

Diff for: test/php-wasm.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</head>
1010
<body>
1111
<script type="php-wasm">
12-
echo 'Hello PHP';
13-
vrzno_run('alert', ['Hello, World!']);
12+
phpinfo();
1413
</script>
14+
<div id="target"></div>
1515
</body>
1616
</html>

0 commit comments

Comments
 (0)