I am using Codeignitor for programming and coming from c#.
its look like a newbie question ,but i want to do something like this.
I have some functions that which return some values :
Example :
function Create_db()
{
//do something
if (PassWordError) //some errors here it is password incorrect
{
return "PASS_ERROR";
}
}
and in some places i am using like this
$result = Create_db(); //assume that there are some problems and returned "PASS_ERROR"
so that the $result is string now,
is there anything like ENUMS in php ? or something like that ?
so that i can do something like this :
if (passWordError)
{
return $error->PasswordError();
}
i assume that i can have some others types too
like
Maximum_name_error,authenticationFailedError etc
Thank you.
A typical approach to doing this in PHP would be to use class constants:
Although I would consider using exceptions instead.