1--TEST-- 2Test substr_count() function (basic) 3--FILE-- 4<?php 5 6echo "***Testing basic operations ***\n"; 7try { 8 substr_count("", ""); 9} catch (\ValueError $e) { 10 echo $e->getMessage() . "\n"; 11} 12try { 13 substr_count("a", ""); 14} catch (\ValueError $e) { 15 echo $e->getMessage() . "\n"; 16} 17var_dump(substr_count("", "a")); 18var_dump(substr_count("", "a")); 19var_dump(substr_count("", chr(0))); 20 21$a = str_repeat("abcacba", 100); 22var_dump(substr_count($a, "bca")); 23 24$a = str_repeat("abcacbabca", 100); 25var_dump(substr_count($a, "bca")); 26var_dump(substr_count($a, "bca", 200)); 27var_dump(substr_count($a, "bca", 200, null)); 28var_dump(substr_count($a, "bca", 200, 50)); 29var_dump(substr_count($a, "bca", -200)); 30var_dump(substr_count($a, "bca", -200, null)); 31var_dump(substr_count($a, "bca", -200, 50)); 32var_dump(substr_count($a, "bca", -200, -50)); 33 34?> 35--EXPECT-- 36***Testing basic operations *** 37substr_count(): Argument #2 ($needle) cannot be empty 38substr_count(): Argument #2 ($needle) cannot be empty 39int(0) 40int(0) 41int(0) 42int(100) 43int(200) 44int(160) 45int(160) 46int(10) 47int(40) 48int(40) 49int(10) 50int(30) 51