Redefine constant
Posted: Wed Jun 17, 2009 9:46 am
I know this is crazy because as its said if you can redifine a constant it wouldn't be a constant but is there a way to remove a certain number of constants from memory and thus redefine them that way? Basically here is my problem:
I have all of my translations in php files that are just a large amount of constants. Stuff like:
and I will save that one as signup-email.en.php. Then if the user is browsing the site in Swedish I just load signup-email.sv.php and that file just has stuff like:
this situation has worked really well for me for like a year but now I have come into a bit of trouble. Basically I am trying to send out mass emails to new users. I have the language these users have been browsing in saved in the DB and so I just get all the new users and their language and cycle through them and send the email in their language. Now the problem is that if this list contains users who have a different language saved I will get the "constant already defined..." error. What I want to do is after each email is sent remove the constants that are used in the email so I can redefine them to send out an email in a different language without getting these errors.
The only other option I can think of is to just do this 1 by 1 which would take forever. I can't just do it by language, I would explain why but it would take forever to explain the whole real system, what I gave you was just a condensed version that reflects my basic problem. Is there any way to do this?
I have all of my translations in php files that are just a large amount of constants. Stuff like:
Code: Select all
define('SIGNUP_EMAIL_BODY', 'body this baby cakes!');
define('SIGNUP_EMAIL_FOOTER', 'dont put your feet on my pillow crazy guy);Code: Select all
define('SIGNUP_EMAIL_BODY', 'swedish translation of what i put in english here (you get the idea');The only other option I can think of is to just do this 1 by 1 which would take forever. I can't just do it by language, I would explain why but it would take forever to explain the whole real system, what I gave you was just a condensed version that reflects my basic problem. Is there any way to do this?