php-wasm
php-wasm copied to clipboard
Header values
Hello, how do I retrieve header values that are set in the script?
const { PhpWeb } = await import("https://cdn.jsdelivr.net/npm/php-wasm/PhpWeb.mjs");
const php = new PhpWeb({ stdout: (x: any) => console.log("out", x), stderr: (x: any) => console.log("err", x) });
let logs: any[] = [];
php.addEventListener("output", (event: any) => logs.push(...event.detail));
const script = "<?php header('Content-Type: image/jpeg'); echo \"Hello, world!\"; ";
const exitCode = await php.run(script);
console.log({ script, exitCode, logs });
I can't seem to figure out how to grab the Content-Type header. Thanks!