Welcome Guest, Not a member yet? Register   Sign In
Method always returns the same value (cache?)
#4

(03-25-2022, 04:27 AM)kenjis Wrote: Can't reproduce.

Code:
$ php public/index.php
almjv976uc
$ php public/index.php
o51xgm4l6e
$ php public/index.php
igcjb9h8kt
$ php -v
PHP 8.0.15 (cli) (built: Jan 20 2022 04:25:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v8.0.15, Copyright (c), by Zend Technologies

PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index()
    {
        echo RS_RANDOM_STRING(10) . PHP_EOL;
    }
}

function 
RS_RANDOM_STRING(int $lengthbool $onlyLetters falsebool $onlyNumbers false): string
{
    $chars '';
    if (!$onlyNumbers || $onlyLetters$chars .= 'abcdefghijklmnopqrstuvwxyz';
    if (!$onlyLetters || $onlyNumbers$chars .= '0123456789';

    $numChars strlen($chars);
    $loop ceil($length $numChars);

    return substr(str_shuffle(str_repeat($chars$loop)), 0$length);


I will try to upload a zip file containing the project where this issue is reproducible.
Reply


Messages In This Thread
RE: Method always returns the same value (cache?) - by RedskyThirty - 03-27-2022, 11:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB