2017 © Pedro Peláez
 

library php-flash-messages

Session-based Flash Messages class for PHP

image

mesingh/php-flash-messages

Session-based Flash Messages class for PHP

  • Saturday, October 26, 2013
  • by mSingh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 640 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 54 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

PHP Session-Based Flash Messages

Copyright 2012 Mike Everhart (http://mikeeverhart.net), (*1)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at, (*2)

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License., (*3)

Description

Stores messages in Session data to be easily retrieved later on. This class includes four different types of messages: * Success * Error * Warning * Information, (*4)

Read more: http://mikeeverhart.net/php/session-based-flash-messages/, (*5)

Basic Usage

add('s', 'This is a success message!');
$msg->add('e', 'This is a error message!');
$msg->add('w', 'This is a Warning message!');
$msg->add('i', 'This is a Information message!');

// If you need to check for errors (ie: when validating a form) you can:
if( $msg->hasErrors() ) {
    // There ARE errors
} else {
    // There are NOT any error
}
    
// Where ever you want to display the messages simply call:
echo $msg->display();

?>

Update

Now you can pass a URL as a third parameter, and the user will get redirected immediately after the message is added:, (*6)

<?php $msg->add('e', 'An error has occurred.', 'http://website.com/page.php'); ?>

The Versions

26/10 2013

dev-master

9999999-dev https://github.com/meSingh/PHP-Flash-Messages

Session-based Flash Messages class for PHP

  Sources   Download

Apache

The Requires

  • php >=5.3.0

 

messages sessions flash php-flash-messages