How do I use PHP's built-in classes in namespaces?
Hello, beginner PHP, encounter problems, ask for advice:
This is the code in a php file. Contains 2 namespaces, Test2 and Test4, Exception class throws an error in Test2
Errors are detected in the test4 space, but the runtime says that the exception class is not found in test2, so the exception class in the Red section
The previous add \ Indicates the root space, but in test4 the catch statement Exception $e error
How can I change the correct, thank you.
Namespace test2{
Class a{
Private $file _id;
Public Function File_open ($path _file_name) {
$this->[email protected] ($path _file_name, ' R ');
if ($this->file_id==false) {throw new \exception ("Path_file_name isnot EXIST");
Echo (NL2BR (sprintf ("File Open failed\n")); }
}
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.