[ create a new paste ] login | about

Link: http://codepad.org/TKigVlCj    [ raw code | output | fork ]

PHP, pasted on Mar 31:
<?php

//....code
error("Field Name is too short, minimum is 12 characters (20 max).");
error("Random Error");
error("Random Error 2");
//.. some code
//at the end of the file:
displayErrors();

function error($msg){
   if(!isset($_SESSION['errors'])) $_SESSION['errors'] = array();
   $_SESSION['errors'][] = $msg;
}

function displayErrors(){
     foreach($_SESSION['errors'] as $err){
         echo $err.'<br/>'.PHP_EOL;
     }
     unset($_SESSION['errors']);
}

?>


Output:
1
2
3
Field Name is too short, minimum is 12 characters (20 max).<br/>
Random Error<br/>
Random Error 2<br/>


Create a new paste based on this one


Comments: