These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | defined( 'WPINC' ) or die; |
||
0 ignored issues
–
show
|
|||
4 | |||
5 | /** |
||
6 | * PSR-4 autoloader |
||
7 | */ |
||
8 | spl_autoload_register( function( $class ) |
||
9 | { |
||
10 | $namespaces = [ |
||
11 | 'GeminiLabs\\Pollux\\' => __DIR__ . '/src/', |
||
12 | 'Symfony\\Component\\Yaml\\' => __DIR__ . '/vendor/symfony/yaml/', |
||
13 | ]; |
||
14 | foreach( $namespaces as $prefix => $base_dir ) { |
||
15 | $len = strlen( $prefix ); |
||
16 | if( strncmp( $prefix, $class, $len ) !== 0 )continue; |
||
17 | $file = $base_dir . str_replace( '\\', '/', substr( $class, $len ) ) . '.php'; |
||
18 | if( !file_exists( $file ) )continue; |
||
19 | require $file; |
||
20 | break; |
||
21 | } |
||
22 | }); |
||
23 |
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.