PHP 5 与 PHP 7 中 $this 差异

foo();

  A::foo();
  $b = new B();
  $b->bar();

  B::bar();
?>

Output of the above example in PHP 5:
$this is defined (A)
$this is not defined.
$this is defined (B)
$this is not defined.

Output of the above example in PHP 7:
$this is defined (A)
$this is not defined.
$this is not defined.
$this is not defined.

你可能感兴趣的:(PHP 5 与 PHP 7 中 $this 差异)