I need some advice. What is the best way to structure my code?
There is the class which holds functions
Then there is the file that calls the class, then the functions to be used, then calls the template file to utilise the functions.
A layout similar to the one below;
Class file: Class:: Function - does calculation (no messages)
Process file: Process - does logic, holds logic (calls function, calls layout template)
Template file: template - holds layout (and for some, holds logic, e.g. loops, tables, etc)
My problem arises from the following, when creating a function, at times it's easier to specify what messages are displayed after a given logic step, for instance for user login
If invalid username
(echo message - wrong username)
else if invalid password
(echo message - wrong password)
But then if this is coded in the function, how can it work with the above structure, as when it's called in the process file, the "echo" message will happen within the process file when teh function is called before being passed onto the template.
Whereas using "return" is also limited and could not output something short.
How would i get messages to be displayed? The right messages being passed onto the template depending on the logic within the function
Does that mean creating a class that handles messages?