请教这个是异常抛出PHP中什么写法?是版本改进嘛?

WBOY
Release: 2016-06-06 20:50:49
Original
1163 people have browsed it

请问下面这段代码是什么意思?是直接取对象的方法嘛?

throw new Exception\RuntimeException('Config is read only')
Copy after login
Copy after login

是不是所有的PHP都可以通过\直接取对象的方法,哪个版本改进的,谁能提供下相关资料

回复内容:

请问下面这段代码是什么意思?是直接取对象的方法嘛?

throw new Exception\RuntimeException('Config is read only')
Copy after login
Copy after login

是不是所有的PHP都可以通过\直接取对象的方法,哪个版本改进的,谁能提供下相关资料

这个就是PHP的namespace特性,便于更好的组织代码结构,防止命名冲突,从5.3.0开始支持的,详见官方文档:
http://www.php.net/manual/en/language...

具体你的代码,调用的类结构如下:

namespace Exception;

class RuntimeException extends Exception{
    function xxx(){...}
}
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template