File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -397,20 +397,28 @@ function createMicrobrewery(string $breweryName = 'Hipster Brew Co.'): void
397397** Not good:**
398398
399399``` php
400- if( $a == $b )
401- {
402- //...
400+ $a = '42';
401+ $b = 42;
402+ Use the simple comparison will convert the string in an int
403+
404+ if( $a != $b ) {
405+ //The expression will always passes
403406}
407+
404408```
409+ The comparison $a != $b return false but in fact it's true !
410+ The string '42' is different than the int 42
405411
406412** Good:**
407-
413+ Use the identical comparison will compare type and value
408414``` php
409- if( $a === $b )
410- {
411- //...
415+ if( $a !== $b ) {
416+ //The expression is verified
412417}
418+
413419```
420+ The comparison $a !== $b return true.
421+
414422** [ ⬆ back to top] ( #table-of-contents ) **
415423
416424
You can’t perform that action at this time.
0 commit comments