gpt4 book ai didi

php - Zend insert 防止特定转义

转载 作者:行者123 更新时间:2023-11-29 13:11:16 25 4
gpt4 key购买 nike

因此,由于我们应用程序中普遍存在的设计决策,我需要能够将回车符插入数据库中。我将信息存储在一个字符串中,然后使用Zend的insert,但是转义了转义字符,所以字符串:

This is an entry\rsplit across two lines

实际上完全按照写入方式插入数据库,字符串中带有文字 \r。我需要在不转义\的情况下插入它,因此实际的回车符会放入数据库中。

Zend Form 有一个文本框和一个多选框。用户可以在文本框中输入文本,按下按钮,然后将其添加到多选框中。我的代码:

$info['choices'] = '';
foreach ($info['choice_list'] as $choice) {
$info['choices'] .= $choice . '\r';
}
$info['choices'] = substr_replace($info['choices'], "", -2);

$info 只是一个表字段数组 => 我传递给 Zend 的 ->update 的值 我在末尾使用 substr_replace 来修剪最后一个 \r

最佳答案

问题已解决,问题是使用单引号而不是双引号。将我的代码更改为:

$info['choices'] = "";
foreach ($info['choice_list'] as $choice) {
$info['choices'] .= $choice . "\r";
}
$info['choices'] = substr_replace($info['choices'], "", -2);

已解决问题。

关于php - Zend insert 防止特定转义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22058921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com