I am trying to make a 12 digit password but the PHP variable sometimes prints only 1 or 3 digits but when I count the string of variable it shows 12.
$caps = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$special = '!@#$%^&*<>?';
$small = 'abcdefghijklmnopqrstuvwxyz';
$digit = '0123456789';
$capsLength = strlen($caps);
$specialLength = strlen($special);
$smallLength = strlen($small);
$digitLength = strlen($digit);
$randomString = '';
for ($i = 0; $i < 3; $i++) {
$randomString .= str_shuffle($caps[mt_rand(0, $capsLength - 1)] . $special[mt_rand(0, $specialLength - 1)] . $small[mt_rand(0, $smallLength - 1)] . $digit[mt_rand(0, $digitLength - 1)]);
}
echo strlen($randomString).'</br>';
echo $randomString;
<then it's probably trying to render it as an HTML tag. Try viewing the source of the page instead, they should be there. If you want it to display properly then you'll need to escape it.var_dump()the string.echo htmlspecialchars($randomString);