What is the correct bit length of MD5 hash and are there better alternatives?

The correct bit length of an MD5 hash is 128 bits. However, MD5 is considered to be a weak hashing algorithm due to vulnerabilities that have been discovered over the years. It is recommended to use more secure hashing algorithms such as SHA-256 or SHA-512 for better security.

// Using SHA-256 hashing algorithm for better security
$password = "password123";
$hashed_password = hash('sha256', $password);
echo $hashed_password;