1 | <?php |
||
20 | class SystemSetting extends Model |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $guarded = ['id']; |
||
27 | |||
28 | /** |
||
29 | * SystemSetting constructor. |
||
30 | * @param array $attributes |
||
31 | */ |
||
32 | 7 | public function __construct(array $attributes = []) |
|
38 | |||
39 | /** |
||
40 | * @param $value |
||
41 | * @return mixed|string |
||
42 | */ |
||
43 | 6 | public function getValueAttribute($value) |
|
47 | |||
48 | /** |
||
49 | * @param $value |
||
50 | * @return string |
||
51 | */ |
||
52 | 6 | public function setValueAttribute($value) |
|
60 | } |
||
61 |
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.