Advertisement
sedran

PHP: An easier way for isset control

Apr 30th, 2011
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  1. function postvars($needle) {
  2.     if( is_array($needle) ) {
  3.         foreach($needle as $item) {
  4.             if( !isset($_POST[$item] ) {
  5.                 return false;
  6.             }
  7.         }
  8.     } else {
  9.         if( !isset($_POST[$needle]) ) {
  10.             return false;
  11.         }
  12.     }
  13.     return true;
  14. }
  15.  
  16. if( postvars( array('multip1', 'multip2') ) ) {
  17.     echo $_POST['multip1']*$_POST['multip2'];
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement