Home > Backend Development > PHP Tutorial > php中@property的作用?解决思路

php中@property的作用?解决思路

WBOY
Release: 2016-06-13 13:28:06
Original
1368 people have browsed it

php中@property的作用?
我发现用@property 申明属性后,类中也可以使用,如下面的代码!请问adminName1和adminName2有什么区别?是不是一般申明属性都用@property?

/**
 * @property string adminName1
 */

class test {

private $adminName2;

public function getName($pram1,$pram2) {
$this->adminName1 = $pram1;
$this->adminName2 = $pram2;
}
}

?>

------解决方案--------------------
你没看到他是在注释里面的吗?

@property string adminName1
是说属性 adminName1 是一个字符串

这只是为了帮助理解程序的说明文字
------解决方案--------------------
你根据它的规则走就是啦。这是出自哪里的代码?
------解决方案--------------------
已经说了 是为了帮助理解程序的说明文字
像你这样一改 
/**
 * @property string adminName1
 */
就没有说明的意义了,相反还会产生误解
明明他说有一个 adminName1 属性,我怎么没看到呀?只看到 adminName2,是不是还要定义一个 adminName1 呀

Related labels:
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