mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-08 15:06:30 +02:00
Update The-Basics.md
Comment "Strict comparisons" over "equality comparisons" code example make confusing.
This commit is contained in:
committed by
GitHub
parent
2080260c85
commit
7d94b0f83c
@@ -20,15 +20,12 @@ var_dump($a == '5'); // compare value (ignore type); return true
|
||||
var_dump($a === 5); // compare type/value (integer vs. integer); return true
|
||||
var_dump($a === '5'); // compare type/value (integer vs. string); return false
|
||||
|
||||
/**
|
||||
* Strict comparisons
|
||||
*/
|
||||
//Equality comparisons
|
||||
if (strpos('testing', 'test')) { // 'test' is found at position 0, which is interpreted as the boolean 'false'
|
||||
// code...
|
||||
}
|
||||
|
||||
// vs.
|
||||
|
||||
// vs. strict comparisons
|
||||
if (strpos('testing', 'test') !== false) { // true, as strict comparison was made (0 !== false)
|
||||
// code...
|
||||
}
|
||||
|
Reference in New Issue
Block a user