1 | <?php |
||
5 | class Password extends NamedFormElement |
||
6 | { |
||
7 | public function __construct($path, $label = null) |
||
16 | |||
17 | /** |
||
18 | * @var bool |
||
19 | */ |
||
20 | protected $allowEmpty = false; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $view = 'form.element.password'; |
||
26 | |||
27 | /** |
||
28 | * @param \Illuminate\Http\Request $request |
||
29 | * |
||
30 | * @return void |
||
31 | */ |
||
32 | public function save(\Illuminate\Http\Request $request) |
||
42 | |||
43 | /** |
||
44 | * @return array |
||
45 | */ |
||
46 | public function getValidationRules() |
||
62 | |||
63 | /** |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function isAllowedEmptyValue() |
||
70 | |||
71 | /** |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function allowEmptyValue() |
||
80 | |||
81 | /** |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function hashWithBcrypt() |
||
90 | |||
91 | /** |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function hashWithMD5() |
||
100 | |||
101 | /** |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function hashWithSHA1() |
||
110 | } |
||
111 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.