I have an osCommerce-shop where I need to access a variable from inside an included php-file. For the sake of simplicity here is a short example of what I am talking about without anything related to osCommerce:
The file inside.php shows a picture and is only displayed on the homepage by being somehow required in index.php. Depending on what language has been selected it should show either picture 1 or 2. Currently only the first picture is displayed because I have no way of knowing which one should be used. Normally there is a $language_id variable which I can check if it is either 1 (english) or 2 (german). Unfortunately $language_id in inside.php is empty (or at least it looks like it) so I need a way to access the variable from index.php. Is there a way to do this without passing this variable or something like that? (Since it is a osCommerce-shop I am not sure how I could to that)
I hope what I tried to explain is somewhat understandable, if not, please ask and I’ll try to clarify.
I assume in your index.php there should have some codes like:
The four including functions: require(),require_once(),include(),include_once(), either will do as inserting code from ‘inside.php’ to ‘index.php’. So code after this inclusion should be able to access $language_id if it was REALLY already set. To check whether $language_id was set before, use