random_bytes to generate cryptographically secure random bytes

echo random_bytes($length);
$length : Length of the random string returned as bytes.

Generates cryptographically secure pseudo-random bytes which can be used as Salts, keys etc.
Available in PHP 7

Example

$str=random_bytes(7);
echo bin2hex($str);
Output ( Refresh this page to to see how the random number changes )