How to Display Alert Message Box in PHP?

03-Apr-2023

.

Admin

Hi Guys,

In this example,I will learn you how to display alert message in php.you can easy and simply display alert message in php.

Alert boxes are used for displaying a warning message to the user. As you know that PHP does not have the feature to popup an alert message box, but you can use the javascript code within the PHP code to display an alert message box. In this way, you can display an alert message box of Javascript in PHP.

Example 1:


<?php

// PHP program to pop an alert

// message box on the screen

// Display the alert box

echo '<script>alert("Welcome to Nicesnippests")</script>';

?>

Example 2:

<?php

// PHP program to pop an alert

// message box on the screen

// Function defnition

function function_alert($message) {

// Display the alert box

echo "<script>alert('$message');</script>";

}

// Function call

function_alert("Welcome to Nicesnippests");

?>

It will help you...

#PHP