SPL provides a series of standard exceptions. In daily use, we should use them scientifically as needed to make our programs more robust. LogicException is derived from the Exception base class and no additional methods are added. The method for throwing a logical exception is similar to that for throwing a standard one. The difference is that a logical exception must be thrown only when an error occurs in application programming. The following shows how to use the LogicException class.
Class App {protected $ _ loaded = false; protected $ _ name; public function start () {$ this-> _ loaded = true; $ this-> _ name = 'unzin';} public function GetName () {if (! $ This-> _ loaded) {throw new LogicException ("Error Processing Request", 1);} return $ this-> _ name ;}} try {$ APP = new App (); echo $ APP-> GetName ();} catch (LogicException $ e) {echo $ e-> getMessage ();}