Is it advisable to use a salt when encrypting passwords in PHP?

When encrypting passwords in PHP, it is highly advisable to use a salt in order to add an extra layer of security to the encryption process. A salt is a random string of characters that is added to the password before hashing, making it harder for attackers to crack the password using techniques like rainbow tables. By using a salt, you can significantly increase the security of your password encryption method.

$password = 'password123';
$salt = 'randomsalt123';

$hashed_password = hash('sha256', $password . $salt);