I am working on PHP and Zend. I have to show different type of error/confirmation messages in application. Most of these messages are placed in code. So if I have to change one message then I have to change it everywhere where this particular type of message is coded.
So what is the best way to store all messages in on place and use them across the application.
Possible solutions:
-
Store all messages in database. (We have to move these messages to other database type. For example if we move from MySQL to SQL Server.)
-
Store all messages in separate php class using array and get these messages using class methods (Problem: We can not use this class in other programming languages.)
-
Store message in special format which acceptable for all languages for example ini type of files.
EDIT: (After looking Ozair’s Answer)
Sometimes we have to change message for particular record. For example:
Product No. 10 is deleted.
Product No. 15 is deleted.
What will be best method to handle this case ?
Thanks
You could have some sort of static class in the library folder. Which would contain a set of constant variables like
The I would have two static methods which take care of displaying the error/message
Than in your code whenever you need to display the message you simply invoke the static class like so…
That way all the messages the application needs will be contained in one class and if need be that the message changes you only have to change it this class.
What do you think?