Menu

[r262]: / trunk / test / bad_strictcompare_4.php  Maximize  Restore  History

Download this file

36 lines (29 with data), 603 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* This file is an exemple of PHP file containing unsafe comparison.
*/
$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';
$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);
// Should be ===
if ($pos1 == false) {
echo 'Not found';
}
// Should be !==
if (false != $pos2) {
echo 'Found';
}
// Should be ===
if (false == stripos($mystring2, $findme)) {
echo 'Found';
}
// Should be ===
if (stripos($mystring2, $findme) == false) {
echo 'Found';
}
// OK
if (false === stripos($mystring2, $findme)) {
echo 'Found';
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.