alert php code example
Example 1: alert in php
echo '<script>alert("Message")</script>';
Example 2: show alert in php
echo '<script language="javascript">alert("juas");</script>';
Example 3: alert a php variable
echo '<script type="text/javascript">alert("'.$error.'");</script>';
Example 4: alert in php
$message = "Something";
echo "<script type='text/javascript'>alert('$message');</script>";
Example 5: allert in php
$message = "wrong answer";
echo "<script type='text/javascript'>alert('$message');</script>";
Example 6: php pop up message
Copy Code<?php
function createConfirmationmbox(){
echo '<script type="text/javascript"> ';
echo 'var inputname = prompt("Please enter your name", "");';
echo 'alert(inputname);';
echo '</script>';
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Prompt Box by PHP</title>
<?php
createConfirmationmbox();
?>
</head>
<body>
</body>
</html>