1--TEST-- 2Bug #36944 (strncmp & strncasecmp do not return false on negative string length) 3--FILE-- 4<?php 5 6try { 7 var_dump(strncmp("test ", "e", -1)); 8} catch (\ValueError $e) { 9 echo $e->getMessage() . \PHP_EOL; 10} 11var_dump(strncmp("test ", "e", 10)); 12var_dump(strncmp("test ", "e", 0)); 13 14try { 15 var_dump(strncasecmp("test ", "E", -1)); 16} catch (\ValueError $e) { 17 echo $e->getMessage() . \PHP_EOL; 18} 19var_dump(strncasecmp("test ", "E", 10)); 20var_dump(strncasecmp("test ", "E", 0)); 21 22?> 23--EXPECTF-- 24strncmp(): Argument #3 ($length) must be greater than or equal to 0 25int(%d) 26int(0) 27strncasecmp(): Argument #3 ($length) must be greater than or equal to 0 28int(%d) 29int(0) 30