Skip to content

Instantly share code, notes, and snippets.

@ryuchan00
Created August 5, 2017 05:35
Show Gist options
  • Save ryuchan00/c8412d38ce8d14c53fb458777cab20b3 to your computer and use it in GitHub Desktop.
Save ryuchan00/c8412d38ce8d14c53fb458777cab20b3 to your computer and use it in GitHub Desktop.
<?php
// mbstrposの誤判定
$keyword2 = 'DEF';
$text2 = 'DEFghi';
// 含まれていないと判定される
// mb_strposの戻り値が'0'の場合、誤判定するため
// mb_strposの判定は'==='で行うこと
if (mb_strpos($text2, $keyword2) == false) {
echo $keyword2 . "は含まれていません" . "\n";
echo mb_strpos($text2, $keyword2) . "文字目" . "\n";
} else {
echo $keyword2 . "は含まれています" . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment