【发布时间】:2017-07-29 10:06:24
【问题描述】:
我正在尝试比较 Codeigniter 中的两个值,但即使值和类型相同,结果也总是错误的。 我在 CodeIgniter 中使用了这段代码。 下面的代码。
$return_name = $this->db->get('feegroup');
$data = $return_name->result();
foreach($data as $d)
{
$name = $d->name;
if(($name) === ($this->input->post("name")))
{
$this->session->set_flashdata('error_message',"Sorry cannot create $name fee group, you cannot have two similar fee groups. Either edit or delete $name fee group or change name to create a new fee group.");
redirect(base_url("feegroup/add"));
}#EOF IF
}#EOF foreach
我使用 trim()、strlen()、is_string() 来查看结果,每次都显示为 true,但在比较相同数据时返回 false。
如果来自 DB 的值来自 Sample 并且如果用户输入 sample 它返回 false 但如果来自 DB 的值来自 Sample 并且如果用户输入 样本它返回True 它不是在检查案例。
例如:
1 父 === 父 = 真
2 父 === 父 = 假
3 父 === Sam = False
4 山姆 === 山姆 = 假
5 heLLO === hello = False
【问题讨论】:
-
你想让`Parent === parent`返回
true吗? -
@HamzaAbdaoui:是的,亲爱的。
标签: php codeigniter