Alternative to enum in PHP -


is there alternative using enums in php? ask because in c# have methods return emum, in php nothing similar exists. here possible return types fictitious method:

function login() {     // logged in     // log in failed verify account     // log in failed account suspended     // log in failed account banned  } 

what's best way in php?

you can use class:

class loginstatus {     const failverifyaccount = 0;     const failaccountsuspended = 1;     const failaccoutbanned = 2; }  // how use $status = loginstatus::failverifyaccount;  if ($status == loginstatus::failverifyaccount) echo "verify account"; 

or constants using define:

define("login_status_verify_account", 0); define("login_status_account_suspended", 1); define("login_status_account_banned", 2);  // how use $status = login_status_verify_account;  if ($status == login_status_verify_account) echo "verify account"; 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -