Created
September 4, 2017 15:17
-
-
Save yuyu-TZ321/fc8d9b083681aa7b1cafa5c307bcf6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Debug | |
{ | |
public function getTest($x) | |
{ | |
if ( !is_numeric($x) ) { | |
throw new Exception('This not number'); | |
} | |
return $x; | |
} | |
} | |
class YuException extends Exception | |
{ | |
public function errorMessage() | |
{ | |
$errorMsg = 'Message: '.$this->getMessage(); | |
return $errorMsg; | |
} | |
} | |
class DebugTwo | |
{ | |
public function getTest($x) | |
{ | |
if ( !is_numeric($x) ) { | |
throw new YuException('This not number'); | |
} | |
return $x; | |
} | |
} | |
$Debug = new Debug(); | |
try { | |
echo $Debug->getTest('1') . "\r\n"; | |
echo $Debug->getTest('A') . "\r\n"; | |
echo $Debug->getTest(0) . "\r\n"; | |
} catch (Exception $e) { | |
echo $e->getMessage()."\r\n"; | |
} | |
$DebugTwo = new DebugTwo(); | |
try { | |
echo $DebugTwo->getTest('1') . "\r\n"; | |
echo $DebugTwo->getTest('A') . "\r\n"; | |
echo $DebugTwo->getTest(0) . "\r\n"; | |
} catch (YuException $e) { | |
echo $e->errorMessage()."\r\n"; | |
} |
dinos80152
commented
Sep 9, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment