summaryrefslogtreecommitdiffhomepage
path: root/php.html.markdown
diff options
context:
space:
mode:
authorCameron Schermerhorn <Cameron.Schermerhorn@its.ny.gov>2015-10-09 13:30:07 -0400
committerCameron Schermerhorn <Cameron.Schermerhorn@its.ny.gov>2015-10-09 13:30:07 -0400
commitd2010c08604c25b3166977e0cde795732ecde551 (patch)
treed4d6d72b9364e85decc55770e1f451f479321b67 /php.html.markdown
parentbf7d33037f64ea9f80f106a37929e3fdf20bd24d (diff)
parentea943b61fbee8fb0ba34f88b4d0380400e890f30 (diff)
Merge remote-tracking branch 'refs/remotes/adambard/master'
Conflicts: java.html.markdown
Diffstat (limited to 'php.html.markdown')
-rw-r--r--php.html.markdown39
1 files changed, 37 insertions, 2 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 93066284..39ec5aef 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -515,7 +515,7 @@ class MyClass
}
}
-// Class constants can always be accessed statically
+// Class constants can always be accessed statically
echo MyClass::MY_CONST; // Outputs 'value';
echo MyClass::$staticVar; // Outputs 'static';
@@ -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).