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

PHP 7.2:如何检查是否处于静态模式

Situation:

Class A{
    public function F(){
        var_dump($this);
    }
}

A::F();

When doing this I get PHP Fatal error:Uncaught Error: Using $this when not in object context.

  1. Shouldn't I get a NULL or something, instead of the error?
  2. How do I check (in PHP 7.2!!!) if in object context?

Thx!

$this is not available in static calls, you need to use self:: but keep in mind these are not interchangeable equivalents.

近期文章

  • 防止元素在php文档中移动 -
  • 关于在时钟输出web应用程序中构建时钟的任何指针
  • 在PHP下拉列表中选择默认选项
  • PHP - 如何使用cookie中的值重定向到个人资料页面
  • 数组计数+1,网站不加载
  • 会话没有被破坏[重复]
  • 使用数组过滤器重写
  • PHP从xml文件中获取特定数据
  • JavaScript和PHP代码无法正常工作
  • 在php上传rtf文件
  • 简单的搜索栏使用MySQL返回没有结果
  • 如何编写此正则表达式与preg_match一起使用?
  • 在bootstrap轮播中导入MYSQL图像
  • 如何从php中的结果中获取json键名?
  • 如何使用PHP将header.html提取到index.html文件中?
  • 使用Facebook Graph api评论facebook组的帖子
  • 如果选择多个,价格会上涨
  • 使用ajax从php文件中检索数据库密码
  • 如何从数组中的特定键获取值?
  • 如何从mysql查询中将多个值放入html表?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华