Skip to content

Instantly share code, notes, and snippets.

@dprevite
Created August 9, 2012 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dprevite/3306562 to your computer and use it in GitHub Desktop.
Save dprevite/3306562 to your computer and use it in GitHub Desktop.
flash_message_helper.php
<?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