过去,当我想在 HTML 中显示文本内容(textarea -> mySQL 数据库)时,我使用 nl2br 在 HTML 中正确显示内容。
现在我想在解密数据库内容后执行此操作,但它不起作用。
$note = openssl_decrypt($note, "AES-256-CBC", "$encode_key", 0 , "$encode_key");
$outputNote = str_replace("\r\n", "test", "$note");
echo $outputNote;
这个解决方案有什么问题?
最佳答案
好的。这就是完整的代码生成注释
$sql_notes = "SELECT content FROM gn_notes WHERE userid = '$sessionID' ORDER BY tstamp DESC";
$result = mysqli_query($db_link, $sql_notes);
$number=mysqli_num_rows($result);
if($number > 0) {
while ($record = mysqli_fetch_assoc($result)) {
$date = date("d.m.Y", $record['tstamp']);
$time = date("H:i", $record['tstamp']);
$note = $record['content'];
/* LOOKING FOR ENCODE_KEY */
$encode_key = getValue('encode_key', 'gn_user', $sessionID, $db_link);
$note = openssl_decrypt($note, "AES-256-CBC", "$encode_key", 0 , "$encode_key");
echo nl2br($note);
}
}
这是网站的输出: Screenshot ouput
关于php - 解密 mySQL 数据库中的记录后使用 nl2br,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45755184/