PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Oren wrote:It really depends. You'll need to tell more.
For now, check out file() and parse_ini_file()
I know how to open a file. I am asking specifically what would be the best way to do this in class context so I can store the variables used by the class in a seperate file.
If I do it like that I will end up with two copies of the variable, one in the object and one in global scope. I don't want that, the array is too big.
If I do it like that I will end up with two copies of the variable, one in the object and one in global scope. I don't want that, the array is too big.
Not strictly true.
PHP will not "copy" anything in memory until you actually make changes to the value. Copy-on-write.
Passing by reference will help if you are writing to the array though.
A class definition is required to be in one (and only one) file. So as already mentionned, you'll have to inject it... Personally i'd choose to do that in the constructor...