Well in my application all 150+ 'lang' variables are stored in a file called lang.php. Since I am rewriting the application in OOP, I am encountering a problem that these lang variables are no longer available when I need them in a class method. For this reason I will have to make some amendments, and I have a few options:
- Define all 'Lang' variables as constants instead, this way they are available everywhere.
- Add a lang property in each class that uses 'lang' variables so the class' methods will have access to them.
- Use keyword 'global' whenever a lang variable is to be used by a class method
Which approach would you recommend me to do? And if you dont like all of them, would you mind giving me some other advices that you think will work for an application with 150+ different system messages? I am not quite sure what to do at this point, and every comment or help is appreciated.
And btw, I recently looked into MyBB's language(lang) class and files, it seems that they are using placeholders such as {1} and {2} in 'lang' variables so that a certain portion of the string can be modified depending on the circumstances. So here comes my question, how does placeholders work? I know PDO can use placeholders, but I still aint familiar with the magic of place holders. Please help.