I my framework I have some functions that when done they can add some messages to a queue for reporting.
Example: I have a function that takes a path of a photo and
- if the image is not .jpg it converts it to .jpg
- if the image is greater than 500kB it reduces its size
I have a global $msgQueue=array();
and whenever all the logic of the page is done, in my template I echo to the users all the reports (that the functions could add during the exectuion).
In that case 2 messages would be added to $msgQueue:
- The image was PNG and has been converted to JPG
- The image was 2000x1000 and now is 1000x500
But this kind of behaviour I think it's not standard. If I want share with someone one of my function (in this case is checkImage($path)
) It can't work because the functions needs that global array to put their report msgs.
Is there a standard approach to solve this so I can share my functions with someone else and don't worry about this dependence?