How to get a random string in php?

This tutorial includes several methods of generating a unique, random, alpha-numeric string with PHP.

1. Code:

    ";
	$str1 = getRandomString(18);
	echo $str1;
    ?> 

2. Example:

Input:

getRandomString(20);
getRandomString(18);

Output:

0XjUEjHU4ZH2PFSHBdyv
Xoe5b4t2m6dTcQWAY7