Email Library Constructor |
Having trouble with this, maybe someone can help.
I have a Library that handles on my email functions. I have 3 environments setup. Development, Test & Production. What I am trying to do is have different application names and mailto addresses depending on the environment. I've tried to do this through constructor but no luck. Basically, I don't want test emails going to real users and I'd like to better distinguish what is test from what is actual data for my testers who are also users... PHP Code: public function __construct() I can get this to work if I put the code directly in each function but it would be so much nicer if it could just all be in one spot!! Sorry for any formatting problems, I am not a forum pro... THANK YOU.
Create three directories inside config directory ("development", "testing", "production"). Inside each of them create a file named email.php, and there put the particular configuration you want to use.
Website: http://avenir.ro
Avenirer has the ideal solution, but if you want to keep the config within the library for some reason, you could do something like:
PHP Code: protected $emailto;
Jay that worked PERFECT! Thank you!!! If possible, what is the reason that $this-> needs to be used and regular variables don't work?
@330Root That is because... OOP?... You are actually working with properties in classes, not with variables. It would take a lot to explain. You should look for OOP tutorials.
In short, those properties are accessible across your class (inside the methods) only if you put $this-> before their name. By using $this->property you are actually tell a method to look for a property of the class with the name of "property". Website: http://avenir.ro
(06-02-2015, 07:08 AM)Avenirer Wrote: @330Root That is because... OOP?... You are actually working with properties in classes, not with variables. It would take a lot to explain. You should look for OOP tutorials. That helps. Thank you very much. Always trying to learn. |
Welcome Guest, Not a member yet? Register Sign In |