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?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

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

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

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

What is new features in Javascript ES2020 ECMAScript 2020

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.

Render HTML with Vanilla JavaScript and lit-html

Sometimes you need to render HTML elements on a web page. And like Goldilocks' search for "just right", you have to try a few techniques before you find the right one. Using a framework may be too hard. Using pure HTML and the DOM API may be too soft. What you need is something in the middle that is just right. Is lit-html "just right"? Let's find out.