// This is in the PHP file and sends a Javascript alert to the client
$message = "wrong answer";
echo "<script type='text/javascript'>alert('$message');</script>";
<?php
//my other php code here
function function_alert() {
// Display the alert box; note the Js tags within echo, it performs the magic
echo "<script>alert('Your message Here');</script>";
}
?>