首页 技术 正文
技术 2022年11月11日
0 收藏 368 点赞 3,856 浏览 1571 个字

php.net

Class member variables are called “properties”.
You may also see them referred to using other terms such as “attributes” or “fields”,
but for the purposes of this reference we will use “properties”.
类的变量成员叫做”属性”,或者叫”字段”、”特征”,在本文档统一称为”属性”。
 They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration.
 This declaration may include an initialization, but this initialization must be a constant value–that is,
 it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
属性声明是由关键字 public,protected 或者 private 开头,然后跟一个普通的变量声明来组成。
属性中的变量可以初始化,但是初始化的值必须是常数,这里的常数是指 PHP 脚本在编译阶段(E compile time)时就可以得到其值,而不依赖于运行(E run-time)时的信息才能求值。

Within class methods non-static properties may be accessed by using -> (Object Operator): $this->property
(where property is the name of the property).

Static properties are accessed by using the :: (Double Colon): self::$property.

The pseudo-variable $this is available inside any class method  when that method is called from within an object context.

$this is a reference to the calling object (usually the object to which the method belongs, but possibly another object,

if the method is called statically from the context of a secondary object).
当一个方法在类定义内部被调用时,有一个可用的伪变量 $this。

$this 是一个到主叫对象的引用(通常是该方法所从属的对象,但如果是从第二个对象静态调用时也可能是另一个对象)。

It is possible to define constant values on a per-class basis remaining the same and unchangeable.

Constants differ from normal variables in that you don’t use the $ symbol to declare or use them.

The default visibility of class constants is public.

The value must be a constant expression, not (for example) a variable, a property, or a function call.

可以把在类中始终保持不变的值定义为常量。在定义和使用常量的时候不需要使用 $ 符号。
常量的值必须是一个定值,不能是变量,类属性,数学运算的结果或函数调用。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,913
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,438
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,252
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,063
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,695
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,733