summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-11-02 04:29:39 +0530
committerGitHub <noreply@github.com>2018-11-02 04:29:39 +0530
commit19ba7e09b46b68bf89a321edb22c49d92b88e0cc (patch)
treee527e9528fa668234d3e1862fbe5b3f8db003bb1
parent7cc32b69a3d000235c099724addbf209234d3e1c (diff)
parentca98611c099b2108c37c603440338d1b7ba6cdfb (diff)
Merge pull request #3383 from divayprakash/fix-php
[php/en] Fix exception handling example
-rw-r--r--php.html.markdown7
1 files changed, 5 insertions, 2 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 3b18aa60..40c9dd01 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -837,11 +837,14 @@ try {
// Handle exception
}
-// When using try catch blocks in a namespaced environment use the following
+// When using try catch blocks in a namespaced environment it is important to
+// escape to the global namespace, because Exceptions are classes, and the
+// Exception class exists in the global namespace. This can be done using a
+// leading backslash to catch the Exception.
try {
// Do something
-} catch (Exception $e) {
+} catch (\Exception $e) {
// Handle exception
}