Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cannot access self:: when no class scope is active

Description

self refers to the curent class of the one. As such, self can only be used inside a class or a trait.

Example

<?php

static::x;

?>

Alternatives

  • Move the code inside a method, in a trait or a class.
  • Use the full name of the class that should be used.