Created
August 9, 2012 17:59
-
-
Save dprevite/3306562 to your computer and use it in GitHub Desktop.
flash_message_helper.php
This file contains 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 | |
/** | |
* Set a flash message to be displayed | |
* | |
* @param string $type The type of message, used for styling (error|success|warning|information) | |
* @param string $message The message to be displayed | |
* | |
* @return void | |
**/ | |
function set_flash_message($type, $message){ | |
$_SESSION['flash_message'] = (object)array( | |
'type' => $type, | |
'message' => $message | |
); | |
} | |
/** | |
* Display the flash message | |
* | |
* @return void | |
**/ | |
function display_flash_message(){ | |
if(isset($_SESSION['flash_message'])){ | |
echo '<div class="msg ' . $_SESSION['flash_message']->type . '">' . $_SESSION['flash_message']->message . '</div>'; | |
unset($_SESSION['flash_message']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment