function create_word(string $alphabet, int $index): string
{
$base = mb_strlen($alphabet);
$fix = 1;
$length = 1;
foreach (range(1, $base) as $k) {
$pow = pow($base, $k);
if ($fix + $pow <= $index) {
$fix += $pow;
$length++;
} else {
break;
}
}
$template = sprintf("%0{$length}d", base_convert($index - $fix, 10, $base));
$replace = implode('', range(0, $base));
return strtr($template, $replace, $alphabet);
}
for ($i = 1; $i <= 81; $i++) {
echo $i . ' = '. create_word("abc", $i) . \PHP_EOL;
} class UserProvider implements UserProviderInterface
{
public function loadUserByUsername($username)
{
return new User();
}
public function refreshUser(UserInterface $user)
{
return new User();
}
public function supportsClass($class)
{
return $class === User::class;
}
} IS_AUTHENTICATED_FULLY: This is similar to IS_AUTHENTICATED_REMEMBERED, but stronger. Users who are logged in only because of a "remember me cookie" will have IS_AUTHENTICATED_REMEMBERED but will not have IS_AUTHENTICATED_FULLY.
IS_AUTHENTICATED_FULLY нужна для проверки прав на критичных страницах, типа смены пароля
Результаты
double(2.8330039978027)
double(0.76963996887207)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
php -d memory_limit=-1 toster3.php
Segmentation fault: 11