Click event on button doesn't seem to fire

Click event on button doesn't seem to fire

I'm not new to HTML or JavaScript, though I don't use them often. I am, however, very new to PHP, and am currently facing a weird issue when trying to get a click event on a button in my HTML which is imbedded in PHP:

I'm not new to HTML or JavaScript, though I don't use them often. I am, however, very new to PHP, and am currently facing a weird issue when trying to get a click event on a button in my HTML which is imbedded in PHP:

<?php
session_start();
if(!(IsSet($_SESSION["username"])) && $_SESSION["username"] == "") {
?>
<!DOCTYPE html>
<html lang="de">
<head>
<title>Blah</title>
<meta charset="utf-8">
</head>
<body>
<button type="button" onclick="function() { alert('Moo!'); }">Some button</button>
</body>
</html>
<?php
} else {
}
?>

Nothing happens when I click on the button. Yes, there's of course more markup in the original, but it's not relevant to my question. The W3C markup validation service says there are no errors, and when I alert moo from a script at the bottom of the body tag it works fine as well. It looks like the click event doesn't fire... Any idea why?

javascript php html

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

HTML JavaScript - Add Javascript File to HTML

Learn HTML and javascript, their uses & importance, html javascript function, javascript tags list, why add javascript file to html, HTML Events with JavaScript etc

How to Upload file using JavaScript and PHP

In this tutorial, I show how you can upload a file using JavaScript AJAX and PHP.

Autocomplete Textbox with Javascript, PHP and MySQL

In this guide, we will walk through how to add autocomplete to a textbox, with the help of jQuery and also an alternative that works with just vanilla Javascript.

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown. W will build a Responsive Website with HTML, CSS, and JavaScript