I've been learning PHP recently, and I came across a concept that confused me a bit - the difference between class variables and instance variables. I understand that variables are used to store data, but I'm not quite sure about the distinction between these two types in the context of object-oriented programming.
From what I gather, class variables are shared among all instances of a class, whereas instance variables are unique to each individual instance. Is my understanding correct? If so, could someone please provide me with some practical examples that highlight when and why I should use one over the other?
I appreciate any help or insights you can provide! Thank you in advance.