我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP - 使用静态属性和方法

If I have a class called Sales, which has only static attributes and methods: - What kind of constructor should I write for this class? - How can I make calls to the methods and attributes of this class inside of its own scope?

You can use self::method(); operator to call it's own methods and attributes..

Constructor

private function __construct()
{
   // Your "heavy" initialization stuff here
}

You can use self::method(); to call a static method from within the same class.

More information on static keyword usage

近期文章

  • 按固定日期间隔选择和分组
  • 如何在PHP中读取多标签excel文件?
  • 流浪者使用nginx拒绝连接
  • MySQL选择具有相同值的3行
  • 我们如何从php中的字符串中替换'\'。
  • 使用Session时PHP条件失败
  • 将wp-admin url更改为其他内容? [重复]
  • 图像操作未在缓存中更新
  • 使用php添加1天的功能[复制]
  • 怎么用JAVA写一个四子棋,带解释和备注的最好是中文备注谢谢大佬
  • 如何查看部门的流
  • 将phpunit升级到最新版本
  • 转换数组值写入文件php
  • php mcrypt to javascript aes integration
  • PHP正则表达式帮助(preg_replace)[关闭]
  • 为什么我存储的MySQL程序如此之慢?
  • 在服务器上是否解压缩了PHP的lib?
  • 计算实际播种者的总数
  • MySQL字段名称进入PHP下拉菜单
  • PHP:根据值确定文本颜色

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华