I’m not really sure how to sum this up as a google question but maybe explaining it in detail will get me better help.
I’m trying to find the equivalent to setting up slots in python in PHP
Python:
class Node:
slots = ('name','desc','blah')
def __init__(self, name, desc, blah):
self.name = name
self.desc = desc
self.blah = blah
Running through an array and I hate trying to remember what position somethings at and doing array[3] or what ever so doing array.blah would be much easier. Is this possible in PHP.
There is only one issue with the approach above and thats it that in an array you can add new values on the fly. I am not sure how slots work exactly since im not familiar with python but looking at the example the keys name, desk and blah should be constant and they are pre-defined. The best approach in that case would be to use class members in my opinion such as
You could of course make the variables public but its not the best approach, instead you should probably implement getters and setters for each variable.