mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 22:40:39 +02:00
[ticket/9574] Remove conditional PHP<5.2 code
There is a large amount of conditional code for PHP < 5.2 that can be removed with phpBB 3.1. PHPBB3-9574
This commit is contained in:
@@ -109,70 +109,26 @@ if (extension_loaded('mbstring'))
|
||||
/**
|
||||
* UTF-8 aware alternative to strrpos
|
||||
* Find position of last occurrence of a char in a string
|
||||
*
|
||||
* Notes:
|
||||
* - offset for mb_strrpos was added in 5.2.0, we emulate if it is lower
|
||||
*/
|
||||
if (version_compare(PHP_VERSION, '5.2.0', '>='))
|
||||
/**
|
||||
* UTF-8 aware alternative to strrpos
|
||||
* @ignore
|
||||
*/
|
||||
function utf8_strrpos($str, $needle, $offset = null)
|
||||
{
|
||||
/**
|
||||
* UTF-8 aware alternative to strrpos
|
||||
* @ignore
|
||||
*/
|
||||
function utf8_strrpos($str, $needle, $offset = null)
|
||||
// Emulate behaviour of strrpos rather than raising warning
|
||||
if (empty($str))
|
||||
{
|
||||
// Emulate behaviour of strrpos rather than raising warning
|
||||
if (empty($str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($offset))
|
||||
{
|
||||
return mb_strrpos($str, $needle);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mb_strrpos($str, $needle, $offset);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* UTF-8 aware alternative to strrpos
|
||||
* @ignore
|
||||
*/
|
||||
function utf8_strrpos($str, $needle, $offset = null)
|
||||
|
||||
if (is_null($offset))
|
||||
{
|
||||
// offset for mb_strrpos was added in 5.2.0
|
||||
if (is_null($offset))
|
||||
{
|
||||
// Emulate behaviour of strrpos rather than raising warning
|
||||
if (empty($str))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return mb_strrpos($str, $needle);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!is_int($offset))
|
||||
{
|
||||
trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
$str = mb_substr($str, $offset);
|
||||
|
||||
if (false !== ($pos = mb_strrpos($str, $needle)))
|
||||
{
|
||||
return $pos + $offset;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return mb_strrpos($str, $needle);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mb_strrpos($str, $needle, $offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user