Reputation: 1546
I am writing a PHP class that is broken down to a few simple function. In the constructor function it calls one other function called processFile. This function calls 5 private functions and does checks. if the check fails it assigns the a message to a $var and i have a flag variable that gets set to 1 when the error has occurred. iam trying to a write something in the function processFile to check if the errorFlag is set, and it it is then not calling the other functions. How would i go about doing this?
Upvotes: 0
Views: 124
Reputation: 7504
You can use exception:
if (...) {
throw new Exception(....);
}
Add try..catch block in script which create this object.
Upvotes: 2