Posted By

ratzo on 05/26/11


Tagged

php


Versions (?)

PHP flash messages class


 / Published in: PHP
 

  1. <?php
  2.  
  3. class Flash {
  4.  
  5. public function set($message, $status) {
  6.  
  7. $_SESSION['flash'] = array(
  8. 'status' => $status,
  9. 'message' => $message
  10. );
  11. return true;
  12.  
  13. }
  14.  
  15. public function show() {
  16.  
  17. if (!empty($_SESSION['flash'])) {
  18.  
  19. echo '<div class="' . $_SESSION['flash']['status'] . '" id="flash">';
  20. echo $_SESSION['flash']['message'];
  21. echo '</div>';
  22.  
  23. unset($_SESSION['flash']);
  24.  
  25. }
  26.  
  27. return true;
  28.  
  29. }
  30.  
  31. }
  32.  
  33. ?>

Report this snippet  

You need to login to post a comment.