note 97080 deleted from language.operators.comparison by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 17:47:27 +0000 |
| Subject: | note 97080 deleted from language.operators.comparison by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217881@lists.php.net to get a copy of this message | ||
Note Submitter: taras dot bogach at gmail dot com
----
Boolean switch usege
<?php
class User_Exception extends Exception{}
class User{
public function register($login,$pass,$passCheck)
switch(false){
case(strlen($pass) >= 5):
throw new User_Exception("Password must be at last 5 chars length");
case($pass == $passCheck):
throw new User_Exception("Password is not confirmed!");
case(strlen($login) >= 5):
throw new User_Exception("Login must be at last 5 chars length");
//Do other checks
default:
//Do registration
return true;
}
}
//...
}
?>