From ca98611c099b2108c37c603440338d1b7ba6cdfb Mon Sep 17 00:00:00 2001 From: Divay Prakash Date: Fri, 2 Nov 2018 04:21:54 +0530 Subject: Fix exception handling example --- php.html.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'php.html.markdown') 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 } -- cgit v1.2.3