19
5hadow
1y

Perfect way for generating random string...

Comments
  • 10
    Looks practical enough to me.
    You didn’t say uniquely random 😂
  • 2
    @IllSlapU yep, the whole codebase is a garbage, mostly we can't even understand the previous devs' logic - but sometimes we find some even worse snippets, like this.
  • 4
    @irene Same here, I don't get it.

    As long as the "rand" functions works well enough it should produce a new random string from given characters every time
  • 4
    @irene, @Froot well yes, at least it works but it's not too pretty and a bit slow for a solution - problem is, there are too many slow and not pretty code in this project, making it unstable and incredibly slow - and a big pain to fix anything
  • 2
    @irene, @Froot also, as now I see, it could simply fail if called.
    strlen returns the string's length, rand's max is inclusive in PHP, so it could reference to an undefined index
  • 0
    It depends on what you want to use it for.
  • 1
    @irene I'm on it. :)
  • 3
    snake_case and camelCase at once
  • 2
    @harrizsb I didn't see it, but it doesn't surprise me xD
  • 0
    Im not a php pro but isnt there a "str_random" function in the php standard library?
  • 0
    I don't see the issue. It works doesn't it?
  • 2
    @FetzenNET not in PHP nativity., unless you use OpenSSL’s random_bytes

    Possibly, some frameworks have a function to do this which would probably work in a similar way.
  • 1
    @DuckyMcDuckFace nope, it also fails as I said above ;)
Your Job Suck?
Get a Better Job
Add Comment