<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
namespace myNamespace{
class MyClass {
public function Show(){
$a = new static('a',1,'b',32,$_GET);
var_dump($a);
}
}
}
Copy after login
输出了 object(myNamespace\MyClass)#2 (0) { }
没看明白这个是干嘛的?
------解决方案-------------------- new static new self 都是实例化当前类, 但是new static只有代码所在的类,就是子类如果没有重写的话那么实例化的就是父类。 而new self就是严格的当前类
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