$randstring
in the function scope is not the same as the scope where you call it. You have to assign the return value to a variable.
$randstring = RandomString();
echo $randstring;
Or just directly echo the return value:
echo RandomString();
Also, in your function you have a little mistake. Within the for loop, you need to use .=
so each character gets appended to the string. By using =
you are overwriting it with each new character instead of appending.
$randstring .= $characters[rand(0, strlen($characters))];