| Conditions | 3 |
| Paths | 3 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 85 | protected static function _substr($string, $start, $end, $encoding = null) |
||
| 86 | { |
||
| 87 | if (function_exists('mb_substr')) { |
||
| 88 | $encoding or $encoding = self::_detectEncoding($string); |
||
|
|
|||
| 89 | |||
| 90 | return mb_substr($string, $start, $end, $encoding); |
||
| 91 | } else { |
||
| 92 | return substr($string, $start, $end); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | } |
||
| 96 |
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
dieintroduces 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 withthrowat this point:These limitations lead to logical operators rarely being of use in current PHP code.