php - Send a functions parameter to an array in another included file? -


i'm trying build user signup class, i'm using language file, i've include class. when user tries signup, want class send user e-mail information. however, text use in mail function language file. in language file, have array call variable username in function in class, can't seem work. searched on internet, couldn't find solution.

if you're wondering language language file in, can tell it's in danish.

------ class file:

class user {   #variables mail   public $mail;   private $lang;           public function __construct(){     global $realname;     require_once ('_lang/class.langdk.inc.php');     require_once ('class.phpmailer.php');     $this->lang = $lang;    }    public function registeruser($realname,$useremail){      echo 'brugeren er oprettet med: ' . $this->lang['welcome'];   } } 

in class.langdk.inc.php, have:

$lang= array(     #mailsetup     'welcome'      => 'hej '. $realname .', velkommen som bruger!', ); 

a possible approach :

echo 'brugeren er oprettet med: ' . str_replace('$realname', $realname, $this->lang['welcome']); 

and :

$lang = array(     'welcome' => 'hej $realname velkommen som bruger!' ); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -