Unexpected behaviour of PHP strripos function

101 views Asked by At

Tracking the cause of a mysterious bug in my program, eventually i discovered this unexpected behaviour of PHP's strripos function:

Test code (Tested with PHP 5.4.24):

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

echo 'strripos: ';
var_dump(strripos(chr(128), chr(128)));

echo '<br>strrpos: ';
var_dump(strrpos(chr(128), chr(128)));

echo '<br>strpos: ';
var_dump(strpos(chr(128), chr(128)));

echo '<br>stripos: ';
var_dump(stripos(chr(128), chr(128)));

?>

Its output:

strripos:

boolean false


strrpos:

int 0


strpos:

int 0


stripos:

int 0

This occurs when the needle argument is a single byte with ASCII code above 127.

I am not sure if this is a bug or not.

0

There are 0 answers