<?php
// BadBoth.php — deliberately broken PHP + JS to test Console Monitor
// --- PHP Errors ---
echo "<h1>PHP + JS Error Test</h1>";
// Undefined variable (notice/warning)
echo "Undefined variable: $doesNotExist<br>";
// Division by zero warning
$x = 42 / 0;
// Trigger a user-level warning
trigger_error("This is a triggered PHP warning", E_USER_WARNING);
// Fatal error (comment this in if you want to stop execution completely)
// nonexistent_function();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BadBoth Test</title>
<style>
body { font-family: system-ui, sans-serif; background:#0b1220; color:#e6edf3; padding:20px; }
button { margin:6px; padding:8px 14px; border:0; border-radius:6px; background:#1f6feb; color:#fff; cursor:pointer; }
</style>
</head>
<body>
<p>This page will throw both PHP and JS errors. Use the buttons for extra JS errors.</p>
<button id="btnRef">Trigger JS ReferenceError</button>
<button id="btnType">Trigger JS TypeError</button>
<button id="btnSyntax">Trigger JS SyntaxError via eval</button>
<script>
// --- Immediate JS error on page load ---
// Try to access a missing DOM node → TypeError
document.getElementById("nope").addEventListener("click", () => {});
// --- Button-driven errors ---
document.getElementById("btnRef").addEventListener("click", () => {
console.log("Triggering ReferenceError…");
console.log(notDeclaredVar); // ReferenceError
});
document.getElementById("btnType").addEventListener("click", () => {
console.log("Triggering TypeError…");
let n = null;
n.trim(); // calling string method on null → TypeError
});
document.getElementById("btnSyntax").addEventListener("click", () => {
console.log("Triggering SyntaxError via eval…");
setTimeout(() => {
eval("function bad({"); // bad syntax
}, 0);
});
</script>
</body>
</html>