summaryrefslogtreecommitdiff
path: root/src/PHP-5.3:Class_Exception_Not_Found.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/PHP-5.3:Class_Exception_Not_Found.adoc')
-rw-r--r--src/PHP-5.3:Class_Exception_Not_Found.adoc31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/PHP-5.3:Class_Exception_Not_Found.adoc b/src/PHP-5.3:Class_Exception_Not_Found.adoc
new file mode 100644
index 0000000..97128fe
--- /dev/null
+++ b/src/PHP-5.3:Class_Exception_Not_Found.adoc
@@ -0,0 +1,31 @@
+PHP-5.3:Class Exception Not Found
+=================================
+:author: Aaron Ball
+:email: nullspoon@iohq.net
+
+== {doctitle}
+
+If in PHP 5.3 (likely just PHP 5) you define a namespace for your current class
+and try to throw a new Exception, it will fail with the following error
+
+----
+Fatal error: Class 'your\current\class\namespace\Exception' not found in YourClass.php on line eleventy-billion.'
+----
+
+The problem is that when PHP fails to find a class in the current namespace
+(other than root of course), it doesn't automagically search the root
+namespace. The Exception object exists in the root namespace (unless you
+created your own) so PHP won't find an it because it doesn't exist in your
+class's defined namespace.
+
+The solution is to define the root namespace before your new Exception
+object.
+
+----
+throw new \Exception('This will do nicely');
+----
+
+Category:PHP
+
+
+// vim: set syntax=asciidoc:

Generated by cgit