Home >Backend Development >PHP Problem >How to use PHP to pop up a warning message box (detailed example)
In the previous article "Find the maximum value from two positive integer values within the specified range through PHP", I introduced to you how to use PHP to find the maximum value from two positive integers within the specified range. Find the maximum value among the values. Interested friends can take a look~
The main content to be explained in this article is "How to use PHP to pop up a warning message box"?
The warning message box is also a prompt box. Everyone's first reaction must be to use js to implement it. This is indeed the case, because PHP is a server-side language and does not support warning message boxes, but! We can use JavaScript code in the PHP body to implement the message box in the pop-up page.
The function of message boxes and prompt boxes is to remind users by displaying some information and messages through pop-up windows.
For example: if the user enters an incorrect value, the warning box can provide a button similar to "OK" to select and continue.
Below we will introduce to you two methods of popping up a warning message box in PHP:
The first one:
<?php echo '<script>alert("欢迎来到PHP中文网!")</script>';
The effect is as follows:
Second method:
<?php function function_alert($message) { echo "<script>alert('$message');</script>"; } function_alert("欢迎来到PHP中文网!快学起来吧!");
The effect is as follows:
Note:
alert()
method is used to display an alert box with a specified message and an OK button.
Syntax
alert(message)
The parameter message represents the plain text (not HTML text) to be displayed in the pop-up dialog box on window.
##<script><code> tag is used to define client-side scripts, such as JavaScript; the <script> element can contain script statements or pass "src" Properties point to external script files; JavaScript is commonly used for image manipulation, form validation, and dynamic content changes. (All major browsers support the <script> tag.) </script>
PHP Video Tutorial" ~ come and learn !
The above is the detailed content of How to use PHP to pop up a warning message box (detailed example). For more information, please follow other related articles on the PHP Chinese website!