File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2312,6 +2312,10 @@ PHP_FUNCTION(str_begins) {
2312
2312
Z_PARAM_STR (needle )
2313
2313
ZEND_PARSE_PARAMETERS_END ();
2314
2314
2315
+ if (needle -> len > haystack -> len ) {
2316
+ RETURN_BOOL (0 );
2317
+ }
2318
+
2315
2319
for (i = 0 ; i < needle -> len ; i ++ )
2316
2320
if (haystack -> val [i ] != needle -> val [i ])
2317
2321
RETURN_BOOL (0 );
@@ -2329,6 +2333,10 @@ PHP_FUNCTION(str_ibegins) {
2329
2333
Z_PARAM_STR (needle )
2330
2334
ZEND_PARSE_PARAMETERS_END ();
2331
2335
2336
+ if (needle -> len > haystack -> len ) {
2337
+ RETURN_BOOL (0 );
2338
+ }
2339
+
2332
2340
for (i = 0 ; i < needle -> len ; i ++ )
2333
2341
if (tolower (haystack -> val [i ]) != tolower (needle -> val [i ]))
2334
2342
RETURN_BOOL (0 );
@@ -2345,6 +2353,10 @@ PHP_FUNCTION(str_ends) {
2345
2353
Z_PARAM_STR (haystack )
2346
2354
Z_PARAM_STR (needle )
2347
2355
ZEND_PARSE_PARAMETERS_END ();
2356
+
2357
+ if (needle -> len > haystack -> len ) {
2358
+ RETURN_BOOL (0 );
2359
+ }
2348
2360
2349
2361
for (i = haystack -> len - 1 , j = needle -> len - 1 ; j >= 0 ; i -- , j -- )
2350
2362
if (haystack -> val [i ] != needle -> val [j ])
@@ -2363,6 +2375,10 @@ PHP_FUNCTION(str_iends) {
2363
2375
Z_PARAM_STR (needle )
2364
2376
ZEND_PARSE_PARAMETERS_END ();
2365
2377
2378
+ if (needle -> len > haystack -> len ) {
2379
+ RETURN_BOOL (0 );
2380
+ }
2381
+
2366
2382
for (i = haystack -> len - 1 , j = needle -> len - 1 ; j >= 0 ; i -- , j -- )
2367
2383
if (tolower (haystack -> val [i ]) != tolower (needle -> val [j ]))
2368
2384
RETURN_BOOL (0 );
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ $testStr = "beginningMiddleEnd";
9
9
var_dump (str_ends ($ testStr , "End " ));
10
10
var_dump (str_ends ($ testStr , "end " ));
11
11
var_dump (str_ends ($ testStr , "en " ));
12
+ var_dump (str_ends ($ testStr , $ testStr ."a " ));
12
13
?>
13
14
--EXPECT--
14
15
bool(true)
15
16
bool(false)
16
17
bool(false)
18
+ bool(false)
Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ $testStr = "beginningMiddleEnd";
9
9
var_dump (str_iends ($ testStr , "End " ));
10
10
var_dump (str_iends ($ testStr , "end " ));
11
11
var_dump (str_iends ($ testStr , "en " ));
12
+ var_dump (str_iends ($ testStr , $ testStr ."a " ));
12
13
?>
13
14
--EXPECT--
14
15
bool(true)
15
16
bool(true)
16
17
bool(false)
18
+ bool(false)
You can’t perform that action at this time.
0 commit comments