<body>
<?php
$message='Here is an alert message written by php';
echo '<script type="text/javascript">window.alert("'.$message.'");</script>';
?>
</body>
<?php
// PHP program to pop an alert
// message box on the screen
// Function definition
function function_alert($message) {
// Display the alert box
echo "<script>alert('$message');</script>";
}
// Function call
function_alert("Welcome to Geeks for Geeks");
?>
<?php
// PHP program to pop an alert
// message box on the screen
// Display the alert box
echo '<script>alert("Welcome to Geeks for Geeks")</script>';
?>
<body>
<?php
$message='Voici un message en javascript écrit par php';
echo '<script type="text/javascript">window.alert("'.$message.'");</script>';
?>
</body>
<script>alert("<?php echo htmlspecialchars('Voici un message en JS écrit par PHP', ENT_QUOTES); ?>")</script>