These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is used to manually include all required PHP files. If you are |
||
4 | * using composer as your dependency manager, you do not need to include this |
||
5 | * file as composer will include all neccessary files automatically. |
||
6 | */ |
||
7 | |||
8 | // Prevent direct file access |
||
9 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | /** |
||
12 | * Load module functions. If this amarkal module has not been loaded, |
||
13 | * functions.php will not return false. |
||
14 | */ |
||
15 | if(false !== (require_once 'functions.php')) |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
16 | { |
||
17 | // Load required classes if not using composer |
||
18 | |||
19 | } |
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.