Hello all,
I have a small question regarding files and PHP. Is there a way in which PHPc an tell if it has already loaded (or required_once) a file during its excecution?
Im asking because I am coding a class and wish to have a language pack feature. Having never attempted one before I thought Id go about it this way:
Have a file. lang.english.php which contains a variable ($LangVar) which is an array of all the required commands etc which may need to be translated.
In the class hane a function which returns the requested element of the array.
EG if i had $CLASS->lang(15); it would return the 15th element of the array.
Easy enough?
Well not really. within this function ($CLASS->lang()) I am querying the database to find out the users language preferance and the assosiated DIR of the pack (lang.english.php).
However everytime the funtion is called it queries the database. to find this out. This can really mount up the query count and slow me down, especially as it is a useless query as require_once prevents the file loading again (right?!).
To cut to the chase: How can i make a conditional statement which will skip the queries if the language pack is already loaded and just return the nth element of the array?
Or is there a FAR easier way of doing this?