Home > Backend Development > PHP Tutorial > 类成员默认访问标识符是什么解决办法

类成员默认访问标识符是什么解决办法

WBOY
Release: 2016-06-13 13:27:23
Original
1223 people have browsed it

类成员默认访问标识符是什么

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
class Person {
  var $name;
  protected $id;
  private $hidden;
  public $username;
}

Copy after login

请问上述代码中的$name类成员变量是什么访问控制?(它后面三个变量依次是protected private public。)


------解决方案--------------------
默认是pubilc

但为了让大家养成良好的习惯和今后对PHP6的适应,建议使用 public 而不是 var
------解决方案--------------------
如果你不声明 那么他就是 public
探讨

引用:

默认是pubilc

但为了让大家养成良好的习惯和今后对PHP6的适应,建议使用 public 而不是 var

哦,function不写访问标识也是public是吧?
我看的PHP书上没说,还真让人困惑,JAVA里不写访问控制符意思和private,public,protected都不一样。
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