Browse Source

Allow substr_compare() to take a negative offset to facilitate start of the

comparison from the end of string.
migration/RELEASE_1_0_0
Ilia Alshanetsky 21 years ago
parent
commit
200d5924cf
  1. 4
      ext/standard/string.c

4
ext/standard/string.c

@ -5770,6 +5770,10 @@ PHP_FUNCTION(substr_compare)
RETURN_FALSE;
}
if (offset < 0) { /* negative offset, start comparison at the end of string */
offset = s1_len + offset;
}
if (len && offset >= s1_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length.");
RETURN_FALSE;

Loading…
Cancel
Save