Guest User

Untitled

a guest
Jun 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Escrito por Rodrigo Nery
  5.  *
  6.  *  Class Loop com while em PHP
  7.  *
  8.  * @param int $count
  9.  * @param array $args
  10.  */
  11. class Loop{
  12.    
  13.     public static $count = 0;
  14.     public static $args = array('Janeiro','Fevereiro','Março','Abril',
  15.                                 'Maio','Junho','Julho','Agosto','Setembro',
  16.                                 'Outubro','Novembro','Dezembro');
  17.        
  18.     public static function getArgs(){
  19.         try{
  20.             if(!is_array(self::$args))throw new Exception('Não é um array!');
  21.                 while(self::$count <= 11){
  22.                     $listar = self::$count++;
  23.                     echo $listar . ' - ' . self::$args[$listar] . '<br>' .PHP_EOL;
  24.                 }
  25.         }catch(LoopException $e){
  26.                 echo $e->getMessage();
  27.         }
  28.     }
  29. }
  30.  
  31. $obj = new Loop;
  32. $obj->getArgs();
Add Comment
Please, Sign In to add comment