We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    I’m working on a big Snippet / Module that requires localized error messages. So I created an include file with an array of error messages... but I am having trouble calling the errors from within the class that I’m using. I think it’s probably just a simple scope type of problem, but I’m missing it.

    My Snippet looks something like this:
    <?php
    include_once('lang/english.inc.php');
    // ... stuff ...
    if ( !file_exists( $filename ) ) {
    	exit($_lang['file_not_found']);		
    }
    // ... more stuff...
    $crud_obj = new Thingy();
    
    ?>


    The error messages in the Snippet work... but then when I’m in my Thingy class, they don’t show. Do I need to pass the $_lang array into the class or something?

    Any ideas? Thanks.


      • 630
      • 39 Posts
      You included the array of error messages on a global level, right? Then you will have to state ’global $_lang;’ at the beginning of your class’ definition. Just try, I’m not quite sure.