Static members in PHP belong to the class itself rather than to any specific object instance. You can access static properties and methods directly using the ClassName:: syntax without creating an object.
self:: is used inside the class to access static membersClassName:: is used outside the classStatic members are declared using the static keyword. Since they are class-level, they cannot access instance-level data using $this.
// Define a class with static property and method
// Call static methods without creating an object
Counter::increment();
Counter::increment();
// Access static property directly from class
echo Counter::$count;
?>
The static property $count starts at 0. Each call to increment() increases it by 1. Since static properties are shared, the final output becomes 2.
Think of static members as a shared whiteboard for the class. Every object sees the same value and modifies the same data.
$thisself:: for internal static accessconst for values that never changeMathHelper class with static add() and multiply() methods