保存寄存器数据时出现“严格标准”错误


Strict Standards error while saving register data

我正在学习一个创建注册和登录系统的教程。我做的每件事都一样,但当我在表格上按提交时,我仍然会遇到一个奇怪的"严格标准"错误。

<?php
require 'pdoconnect.php';
$message = '';
if(!empty($_POST['email']) && !empty($_POST['password'])):

// Enter the new user in the database
$sql = "INSERT INTO users (email, password) VALUES (:email, :password)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
if( $stmt->execute() ):
    $message = 'Successfully created new user';
else:
    $message = 'Sorry there must have been an issue creating your account';
endif;
endif;
?>

上面写着

严格的标准:只有变量应该在第14行(带有密码散列的行)通过引用传递。

我到处寻找解决方案,但找不到。

在绑定之前对密码进行哈希:

// Enter the new user in the database
$sql = "INSERT INTO users (email, password) VALUES (:email, :password)";
$stmt = $conn->prepare($sql);
$hashedPass = password_hash($_POST['password'], PASSWORD_BCRYPT);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', $hashedPass );

不能将函数传递给绑定参数,只能传递变量。