summaryrefslogtreecommitdiffhomepage
path: root/php.html.markdown
diff options
context:
space:
mode:
authorZachary Ferguson <zfergus2@users.noreply.github.com>2015-10-15 14:48:59 -0400
committerZachary Ferguson <zfergus2@users.noreply.github.com>2015-10-15 14:48:59 -0400
commit65bb71f4bde383a4d0b8cd6fd49901bb6e2cfa5f (patch)
tree03802f50ac31b295ace0585ccb6bc1ea6ef9b612 /php.html.markdown
parenta4ea3961744c3c1ee6fcf654f011caa8dbadf56e (diff)
parent68953bd9d97328b8660dad06edd8acb8ff330ede (diff)
Merge remote-tracking branch 'refs/remotes/adambard/master'
Conflicts: c.html.markdown
Diffstat (limited to 'php.html.markdown')
-rw-r--r--php.html.markdown37
1 files changed, 36 insertions, 1 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 2b1fe1dc..39ec5aef 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -693,8 +693,43 @@ use My\Namespace as SomeOtherNamespace;
$cls = new SomeOtherNamespace\MyClass();
+/**********************
+* Error Handling
+*
*/
+// Simple error handling can be done with try catch block
+
+try {
+ // Do something
+} catch ( Exception $e) {
+ // Handle exception
+}
+
+// When using try catch blocks in a namespaced enviroment use the following
+
+try {
+ // Do something
+} catch (\Exception $e) {
+ // Handle exception
+}
+
+// Custom exceptions
+
+class MyException extends Exception {}
+
+try {
+
+ $condition = true;
+
+ if ($condition) {
+ throw new MyException('Something just happend');
+ }
+
+} catch (MyException $e) {
+ // Handle my exception
+}
+
```
## More Information
@@ -709,4 +744,4 @@ If you're coming from a language with good package management, check out
[Composer](http://getcomposer.org/).
For common standards, visit the PHP Framework Interoperability Group's
-[PSR standards](https://github.com/php-fig/fig-standards). \ No newline at end of file
+[PSR standards](https://github.com/php-fig/fig-standards).