0
What is the difference between an object variable and a class variable?
I can't tell the difference between the two in PHP language, I would like to understand how we declare an object variable and where we place them in a program in general.
1 Odpowiedź
+ 2
A variable which is not object dependent and is created only once per class and whose memory is shared by all the objects of the class is called a class variable.
For eg- static variables in Java.
A variable which is object dependent and is created every time a new object is created is called an object variable.
In this example you can see that only one copy of "x" is created which is updated every time you change its value because it is a class variable.
https://code.sololearn.com/c0QPGa6lLf3E/?ref=app