An alert box is used in the website to display a warning message to the user that they have entered the wrong value other than what is required to fill in that position. An alert box can still be used for friendlier messages. The alert box gives only one button “OK” to select and proceed.
The alert message just like a pop-up window on the screen. Using this you can alert to the user with some information and message. PHP doesn’t support alert message box because it is a server-side language but you can use JavaScript code within the PHP body to alert the message box on the screen.
Syntex:
alert("Message")
Program 1: PHP program to pop up an alert box on the screen.
<?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>'; ?> |
Output:

Program 2: PHP program to pop up an alert box on the screen.
<?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 Geeks for Geeks"); ?> |
Output:

Recommended Posts:
- Difference between alert box and confirmation box in JavaScript
- How to change the style of alert box using CSS ?
- How to display error without alert box using JavaScript ?
- How to add a new line in the alert box ?
- How to create a pop-up to print dialog box using JavaScript?
- How to Display Changed Browser URL Without Reloading Through alert using JavaScript ?
- How to Remove extra right margin when using alert-dismissible ?
- HTML | Window alert( ) Method
- How to load notification alert on top right corner without click of button in bootstrap ?
- How to get array structure with alert() in JavaScript?
- How to change Input box borders after filling the box using JavaScript ?
- PHP | Ds\Deque pop() Function
- PHP | Ds\Sequence pop() Function
- PHP | Ds\Vector pop() Function
- PHP | Ds\Stack pop() Function
- PHP Ds\PriorityQueue pop() Function
- PHP | SplDoublyLinkedList pop() Function
- PHP | ImagickDraw pop() Function
- PHP Ds\Queue pop() Function
- How to create automatic pop-up using jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

