You could use Javascript:

// This is in the PHP file and sends a Javascript alert to the client
$message = "wrong answer";
echo "<script type='text/javascript'>alert('$message');</script>";
Answer from Peter Gluck on Stack Overflow
🌐
Simplilearn
simplilearn.com › home › resources › software development › alert in php: displaying an alert message box in php
Alert in PHP: Displaying An Alert Message Box in PHP
January 26, 2025 - Deep dive into alert in PHP tutorial and learn how to display an ⚠️ alert message box in PHP, types of pop-up boxes with examples. Start learning now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Scaler
scaler.com › home › topics › php alert
PHP alert - Scaler Topics
April 1, 2024 - Alert in php is not inherently available as it is in other programming languages like JavaScript. PHP is primarily a server-side scripting language used for processing data and generating dynamic web content.
🌐
STechies
stechies.com › display-alert-message-box-dialogue-box-using-php
How to Display Alert Message Box in PHP?
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.
🌐
Medium
medium.com › @shahmarufsirajmugdho › how-to-use-alerts-in-php-7e5e637a7277
How to Use Alerts in PHP. Alerts are essential for user feedback… | by Shahmaruf Siraj Mugdho | Medium
August 10, 2025 - <?php $username = "JohnDoe"; $login_count = 5; echo "<script>alert('Welcome back, $username! You have logged in $login_count times.');</script>"; ?>
🌐
PHP
php.net › manual › en › seaslog.alert.php
PHP: SeasLog::alert - Manual
Return TRUE on record log information success, FALSE on failure. ... <?php var_dump(SeasLog::alert('log message')); //with content var_dump(SeasLog::alert('log message from {NAME}',array('NAME' => 'neeke'))); //with tmp logger var_dump(SeasLog::alert('log message from {NAME}',array('NAME' => 'neeke'),'tmp_logger')); var_dump(SeasLog::getBuffer()); ?>
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-pop-an-alert-message-box-using-php
How to Pop an Alert Message Box using PHP? - GeeksforGeeks
July 12, 2025 - 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.
🌐
Javatpoint
javatpoint.com › php-alert
PHP alert - javatpoint
PHP alert with examples, php file, php session, php date, php array, php form, functions, time, xml, ajax, php mysql, regex, string, oop, addslashes(), addcslashes() etc.
Find elsewhere
🌐
MojoAuth
mojoauth.com › special-characters › alert-bell-a-in-php
Alert (Bell) (\a) in PHP | Understanding Special Characters in Programming
In PHP, the Alert (Bell) character can be included in strings to generate a sound when the output is rendered in a console that supports such features. When a script containing \a is executed, the console or terminal interprets the character ...
🌐
SitePoint
sitepoint.com › php
Php - alert box - PHP - SitePoint Forums | Web Development & Design Community
December 3, 2010 - index.php · <?php if(isset($_GET['txtError'])) { echo '<script type="text/javascript">alert("'.$_GET['txtError'].'")</script>'; unset($_GET['txtError']); } ?> <form action="formProcessor.php" method="post" > <select name="selStory"> <option value="0">Select a story</option> <option value="1">Story 1</option> <option value="2">Story 2</option> <option value="3">Story 3</option> </select> <input type="submit" value="submit" /> </form> formProcessor.php ·
🌐
Delft Stack
delftstack.com › home › howto › php › php alert message
How to Alert Message Using PHP | Delft Stack
March 11, 2025 - This tutorial demonstrates different ways to show alert messages using PHP. Learn how to implement simple alerts, integrate with HTML forms, use session variables for persistent messages, and enhance user experience with SweetAlert. Discover effective techniques to improve feedback in your web applications.
🌐
W3Schools
w3schools.com › howto › howto_js_alert.asp
How To Create an Alert Message Box
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
GitHub
gist.github.com › rpmahoney › 7bf3e7c901b77ea7129ed0846b399929
PHP functions to create Bootstrap 3 Alerts · GitHub
PHP functions to create Bootstrap 3 Alerts. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › blessedjasonmwanza › phpalert
GitHub - blessedjasonmwanza/phpalert: Enjoy beautiful Alerts inspired by SweetAlert using PHP Alert.
How to use PHP Alert. ... <?php include 'PHPAlert/phpalert.php'; $alert = PHPAlert(); //Lets check if setup was successful $alert->success("You have successfully setup PHP ALERT") ?>
Author   blessedjasonmwanza
🌐
Edureka Community
edureka.co › home › community › categories › web development › php › how to show an alert box in php
How to show an alert box in PHP | Edureka Community
November 4, 2020 - I want to display an alert box showing a message with PHP. Here is my PHP code: But it is not working.
🌐
SSOJet
ssojet.com › special-characters › alert-bell-a-in-php
Alert (Bell) (\a) in PHP | Special Characters in Programming Languages
Implement the alert (bell) character `\a` in PHP for audible notifications. Trigger system beeps programmatically for alerts and user feedback.
🌐
YouTube
youtube.com › watch
Alert Message In PHP - YouTube
Alert Message In PHP#LearnPHP#ProgramSnippet
Published   May 31, 2022