Created
November 15, 2016 02:56
-
-
Save rpmahoney/7bf3e7c901b77ea7129ed0846b399929 to your computer and use it in GitHub Desktop.
PHP functions to create Bootstrap 3 Alerts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Create a bootstrap success alert | |
| * @param String $bold - First words in the alert. Will be put inside <strong> html tag for emphasis | |
| * @param String $message - What will be used for the main description in the alert | |
| */ | |
| function successAlert($bold, $message){ | |
| echo '<div class="container"> | |
| <div class="alert alert-success fade in"> | |
| <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
| <strong>'.$bold.'</strong> '.$message.' | |
| </div> | |
| </div>'; | |
| } | |
| /** | |
| * Create a bootstrap danger alert | |
| * @param String $bold - First words in the alert. Will be put inside <strong> html tag for emphasis | |
| * @param String $message - What will be used for the main description in the alert | |
| */ | |
| function dangerAlert($bold, $message){ | |
| echo '<div class="container"> | |
| <div class="alert alert-danger fade in"> | |
| <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
| <strong>'.$bold.'</strong> '.$message.' | |
| </div> | |
| </div>'; | |
| } | |
| /** | |
| * Create a bootstrap info alert | |
| * @param String $bold - First words in the alert. Will be put inside <strong> html tag for emphasis | |
| * @param String $message - What will be used for the main description in the alert | |
| */ | |
| function infoAlert($bold, $message){ | |
| echo '<div class="container"> | |
| <div class="alert alert-info fade in"> | |
| <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
| <strong>'.$bold.'</strong> '.$message.' | |
| </div> | |
| </div>'; | |
| } | |
| /** | |
| * Create a bootstrap warning alert | |
| * @param String $bold - First words in the alert. Will be put inside <strong> html tag for emphasis | |
| * @param String $message - What will be used for the main description in the alert | |
| */ | |
| function warningAlert($bold, $message){ | |
| echo '<div class="container"> | |
| <div class="alert alert-warning fade in"> | |
| <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
| <strong>'.$bold.'</strong> '.$message.' | |
| </div> | |
| </div>'; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php include 'Alert.php';?> | |
| <html> | |
| <head> | |
| <title>Bootstrap Alert PHP</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h2>Alerts</h2> | |
| <!-- Just call the alert function you need and send in two strings - the alert header and the alert message --> | |
| <?php | |
| successAlert("Success!","This is a Bootstrap success alert"); | |
| infoAlert("Info!","This is a Bootstrap info alert"); | |
| warningAlert("Warning!","This is a Bootstrap warning alert"); | |
| dangerAlert("Danger!","This is a Bootstrap danger alert"); | |
| ?> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment