php - replace die to stop process -


i'm using die stop process when error:

main class:

class myclass {      public function mymethod () {          $helper->checkparameter( $thisparametercannotbeempty );      }  } 

and helper

class control {      public function checkparameter ( $param ) {          if ( $param == "" ) {              echo "parameter can not empty";             die;          }      }  } 

like if parameter empty have error message , process stopped.

but problem want use unit tests (with phpunit) , die stop process (ok) , unit tests execution (not ok).

with zend 1.12, possible stop process calling view or instead of kill php process ?

thx

like @leggendario said, use must use exceptions.

class control {     public function checkparameter ( $param )     {         if ( $param == "" ) {             throw new \exception("parameter can not empty");         }     } } 

the \ before exception tells php use built in namespace exception.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -