PHP strpos () для меня чувствителен к регистру - PullRequest
0 голосов
/ 08 ноября 2011

Когда я использую strpos(), он чувствителен к регистру.Зачем?Разве это не должно быть?

PHP v5.3.8

$file_check_result = "%PDF-1.6 %âãÏÓ";
$test = strpos($file_check_result, "pdf");
echo $test;

ничего не выводит;однако, если я изменю pdf на PDF в strpos, это показывает положение.Почему?

Ответы [ 2 ]

15 голосов
/ 08 ноября 2011

stripos - это функция, которую вы ищете. strpos чувствителен к регистру

http://php.net/manual/en/function.stripos.php

3 голосов
/ 13 января 2016

Без учета регистра: stripos (обратите внимание на i ):

strpos()   // Finds the position of the first occurrence (case-sensitive)
stripos()  // Finds the position of the first occurrence (case-insensitive)
strrpos()  // Finds the position of the last occurrence (case-sensitive)
strripos() // Finds the position of the last occurrence (case-insensitive)
...