Home  >  Article  >  Backend Development  >  php类的属性

php类的属性

WBOY
WBOYOriginal
2016-06-06 20:16:181111browse

php类的属性
为何这样给类的属性定义值,会出错啊?
我的思考是因为不能给属性分配内存空间,希望各位大大给解释下啊?

回复内容:

php类的属性
为何这样给类的属性定义值,会出错啊?
我的思考是因为不能给属性分配内存空间,希望各位大大给解释下啊?

多看看文档吧。

属性中的变量可以初始化,但是初始化的值必须是常数,这里的常数是指 PHP 脚本在编译阶段时就可以得到其值,而不依赖于运行时的信息才能求值。

http://php.net/manual/zh/language.oop5.properties.php

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