Generate Random String in PHP

Method 1: Using substr() with str_shuffle()

gXvcQNWhYZykjqP3eAmECuFfUz4oTVaB

Method 2: Using bin2hex() with random_bytes()

8f65036e7ca2b82b7dae6282c3b079b3

Method 3: Using bin2hex() with openssl_random_pseudo_bytes()

57e953c10028ddd8cec8feb9b0a34e62

Method 4: Using rand() with sha1() hashing

51109c05e29ed176daf0929a0d3bbed5

Method 5: Using custom random characters

fnPnrM3Nms4JFS0MYLDIFINNIR45Hgtz