1Copy Code<?php
2function createConfirmationmbox(){
3 echo '<script type="text/javascript"> ';
4 echo 'var inputname = prompt("Please enter your name", "");';
5 echo 'alert(inputname);';
6 echo '</script>';
7}
8?>
9<!doctype html>
10<html>
11<head>
12<meta charset="utf-8">
13<title>JavaScript Prompt Box by PHP</title>
14<?php
15 createConfirmationmbox();
16?>
17</head>
18<body>
19</body>
20</html>
1Copy Code<script Type="javascript">alert("JavaScript Alert Box by PHP")</script>
1Copy Code<!doctype html>
2<html>
3<head>
4<meta charset="utf-8">
5<title>JavaScript Alert Box by PHP</title>
6<?php
7function_alert("We welcome the New World");
8
9function function_alert($msg) {
10 echo "<script type='text/javascript'>alert('$msg');</script>";
11}
12?>
13</head>
14<body>
15</body>
16</html>
1Copy Code<?php
2function createConfirmationmbox(){
3 echo '<script type="text/javascript"> ';
4 echo ' function openulr(newurl) {';
5 echo ' if (confirm("Are you sure you want to open new URL")) {';
6 echo ' document.location = newurl;';
7 echo ' }';
8 echo '}';
9 echo '</script>';
10}
11?>
12<!doctype html>
13<html>
14<head>
15<meta charset="utf-8">
16<title>JavaScript Alert Box by PHP</title>
17<?php
18createConfirmationmbox();
19?>
20</head>
21<body>
22<strong><a href="javascript:openulr('newurl.html');">Open new URL</a></strong>
23</body>
24</html>
1Copy Code<!doctype html>
2<html>
3<head>
4<meta charset="utf-8">
5<title>JavaScript Alert Box by PHP</title>
6<?php
7echo '<script type="text/javascript">';
8echo ' alert("JavaScript Alert Box by PHP")'; //not showing an alert box.
9echo '</script>';
10?>
11</head>
12
13<body>
14</body>
15</html>
1Copy Code<!doctype html>
2<html>
3<head>
4<meta charset="utf-8">
5<title>JavaScript Alert Box by PHP</title>
6<script type="text/javascript"> function openulr(newurl) { if (confirm("Are you sure you want to open new URL")) { document.location = newurl; }}</script></head>
7<body>
8<strong><a href="javascript:openulr('newurl.html');">Open new URL</a></strong>
9</body>
10</html>
1Copy Code<script type="text/javascript"> var inputname = prompt("Please enter your name", "");alert(inputname);</script></head>