Home  >  Article  >  Backend Development  >  php的基础有关问题请问一下

php的基础有关问题请问一下

WBOY
WBOYOriginal
2016-06-13 12:14:29890browse

php的基础问题请教一下

class Test1 {<br />	static private $_name;<br /><br />}<br /><br /><br />$_test1 = new Test1('张三');<br />var_dump($_test1);


页面输出的是:
object(Test1)#1 (0) { } 
我实例化的时候还传递了参数,但是Test1的类中我没有写构造方法__construct(),为什么不会报错呢?



------解决思路----------------------
构造方法也不是必须的,你传参数进去,它不执行就是了
------解决思路----------------------
构造函数已知都在,你不定义只是那个函数为空。
------解决思路----------------------

class Test1 {
    static private $_name;
}
并没有定义构造函数 __construct

Statement:
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