I am creating a signup form using PHP and MYSQL database. I am getting an error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given in C:\xampp\htdocs\form\signup.php:104 Stack trace: #0 C:\xampp\htdocs\form\signup.php(104): password_hash('hello123', '2y', NULL) #1 {main} thrown in PHP. I want to convert simple text to hash pattern using password_hash() function but getting TypeError: password_hash(): Argument #3 ($options) must be of type array, null given error .
I tried PHP code -
<?php
password_hash('hello123', '2y', NULL)
?>
Is there any solution to fix it?
According to this error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given you passed third parameter null. This error comes when you pass the third parameter null. According to this error, you cannot pass the third optional parameter as null value. Focus on your error Argument #3 ($options) must be of type array. It's saying the third parameter should be an array type.
$password='admin@123';
$options = array("cost"=>4);
$password = password_hash($password,PASSWORD_BCRYPT,$options);
In the solution above I created an array type and pass in the third parameter. You can check reference here -
The third parameter should be an array type in the password_has() function.
You are passing the Null value in the third parameter. Change it like this -
This is totally wrong way to convert simple text to the hash pattern in PHP -
password_hash('hello123', '2y', NULL)
Change above code like this -
$arr = array("cost"=>4);
password_hash('hello123','PASSWORD_BCRYPT',$arr)
This is the solution of your error Uncaught TypeError: password_hash(): Argument #3 ($options) must be of type array, null given .