1--TEST-- 2Test mb_strstr() function : variation - case sensitivity 3--SKIPIF-- 4<?php 5extension_loaded('mbstring') or die('skip'); 6function_exists('mb_strstr') or die("skip mb_strstr() is not available in this build"); 7?> 8--FILE-- 9<?php 10/* Prototype : string mb_strstr(string haystack, string needle[, bool part[, string encoding]]) 11 * Description: Finds first occurrence of a string within another 12 * Source code: ext/mbstring/mbstring.c 13 * Alias to functions: 14 */ 15 16echo "*** Testing mb_strstr() : variation ***\n"; 17 18mb_internal_encoding('UTF-8'); 19 20//ascii 21$string_ascii = b'abcdef'; 22$needle_ascii_upper = b"BCD"; 23$needle_ascii_mixed = b"bCd"; 24$needle_ascii_lower = b"bcd"; 25 26//Greek string in lower case UTF-8 27$string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J'); 28$needle_mb_upper = base64_decode('zpzOnc6ezp8='); 29$needle_mb_lower = base64_decode('zrzOvc6+zr8='); 30$needle_mb_mixed = base64_decode('zpzOnc6+zr8='); 31 32echo "-- Ascii data --\n"; 33// needle should be found 34var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii_lower))); 35// no needle should be found 36var_dump(mb_strstr($string_ascii, $needle_ascii_upper)); 37var_dump(mb_strstr($string_ascii, $needle_ascii_mixed)); 38 39echo "-- mb data in utf-8 --\n"; 40// needle should be found 41$res = mb_strstr($string_mb, $needle_mb_lower, false); 42if ($res !== false) { 43 var_dump(bin2hex($res)); 44} 45else { 46 echo "nothing found!\n"; 47} 48// no needle should be found 49var_dump(mb_strstr($string_mb, $needle_mb_upper)); 50var_dump(mb_strstr($string_mb, $needle_mb_mixed)); 51 52 53?> 54===DONE=== 55--EXPECT-- 56*** Testing mb_strstr() : variation *** 57-- Ascii data -- 58string(10) "6263646566" 59bool(false) 60bool(false) 61-- mb data in utf-8 -- 62string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" 63bool(false) 64bool(false) 65===DONE=== 66