[web-php] master: interactive-examples.js: Fix handling on newlines (multiple newlines collapsed)
| From: | AllenJB via Derick Rethans | Date: | Sat, 04 Oct 2025 14:10:20 +0000 |
| Subject: | [web-php] master: interactive-examples.js: Fix handling on newlines (multiple newlines collapsed) | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-33257@lists.php.net to get a copy of this message | ||
Author: AllenJB (AllenJB)
Committer: Derick Rethans (derickr)
Date: 2025-10-04T15:10:18+01:00
Commit: https://github.com/php/web-php/commit/55be0cb1b89c4ad9e0a96140d945370a54f98499
Raw diff: https://github.com/php/web-php/commit/55be0cb1b89c4ad9e0a96140d945370a54f98499.diff
interactive-examples.js: Fix handling on newlines (multiple newlines collapsed)
Changed paths:
A js/php-web-README.md
M js/interactive-examples.js
Diff:
diff --git a/js/interactive-examples.js b/js/interactive-examples.js
index 7e67c952e3..7f2d41e90c 100644
--- a/js/interactive-examples.js
+++ b/js/interactive-examples.js
@@ -36,22 +36,21 @@ class PHP {
if (PHP.runPhp) {
return PHP.runPhp;
}
+ let initializing = true;
const { ccall } = await phpBinary({
print(data) {
- if (!data) {
+ // The initial exec to get PHP version causes empty output we don't want
+ if (initializing) {
return;
}
-
- if (PHP.buffer.length) {
- PHP.buffer.push("\n");
- }
- PHP.buffer.push(data);
+ PHP.buffer.push(data + "\n");
},
});
PHP.version = ccall("phpw_exec", "string", ["string"],
["phpversion();"]),
console.log("PHP wasm %s loaded.", PHP.version);
+ initializing = false;
PHP.runPhp = (code) => ccall("phpw_run", null, ["string"],
["?>" + code]);
return PHP.runPhp;
}
diff --git a/js/php-web-README.md b/js/php-web-README.md
new file mode 100644
index 0000000000..125aa7709b
--- /dev/null
+++ b/js/php-web-README.md
@@ -0,0 +1,2 @@
+These files are built by [emcripten](https://github.com/emscripten-core/emscripten)
+via https://github.com/derickr/php-wasm-builder