File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -390,34 +390,38 @@ function createMicrobrewery(string $breweryName = 'Hipster Brew Co.'): void
390
390
391
391
## Comparison
392
392
393
- ** [ ⬆ back to top] ( #table-of-contents ) **
394
-
395
393
### Use [ identical comparison] ( http://php.net/manual/en/language.operators.comparison.php )
396
394
397
395
** Not good:**
398
396
397
+ The simple comparison will convert the string in an integer.
398
+
399
399
``` php
400
400
$a = '42';
401
401
$b = 42;
402
- // Use the simple comparison that will convert the string in an int
403
402
404
- if( $a != $b ) {
403
+ if ( $a != $b) {
405
404
// The expression will always pass
406
405
}
407
-
408
406
```
409
- The comparison $a != $b returns false but in fact it's true!
410
- The string '42' is different than the int 42.
407
+
408
+ The comparison ` $a != $b ` returns ` FALSE ` but in fact it's ` TRUE ` !
409
+ The string ` 42 ` is different than the integer ` 42 ` .
411
410
412
411
** Good:**
413
- Use the identical comparison will compare type and value
412
+
413
+ The identical comparison will compare type and value.
414
+
414
415
``` php
415
- if( $a !== $b ) {
416
- //The expression is verified
417
- }
416
+ $a = '42';
417
+ $b = 42;
418
418
419
+ if ($a !== $b) {
420
+ // The expression is verified
421
+ }
419
422
```
420
- The comparison $a !== $b returns true.
423
+
424
+ The comparison ` $a !== $b ` returns ` TRUE ` .
421
425
422
426
** [ ⬆ back to top] ( #table-of-contents ) **
423
427
You can’t perform that action at this time.
0 commit comments