Is using MD5 for generating security tokens in PHP considered secure, especially for login forms?

Using MD5 for generating security tokens in PHP is not considered secure as MD5 is a weak hashing algorithm that can be easily cracked. It is recommended to use stronger hashing algorithms like SHA-256 or SHA-512 for generating security tokens, especially for login forms.

$token = hash('sha256', uniqid(mt_rand(), true));