doupingyun73833 2018-08-31 14:53
浏览 57

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!

  • 写回答

1条回答 默认 最新

  • doufu8887 2018-08-31 15:22
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器