繁体   English   中英

Codeigniter if否则uri segment double if

[英]Codeigniter if else uri segment double if

我有codeigniter代码,并且如果要使用uri段创建URL,则第一行效果很好,但是我很难为第二行隐藏此URL的段2

我想让url为domain.com/favorite将显示为true,domain.com / favorite / me将显示为false,否则为false

  <?php if ($this->uri->segment(1) == "favorite") { echo "True"; } elseif ($this->uri->segment(1,2) == "favorite/me") { echo "False"; } else { echo "false"; } ?> 

我有这个脚本为我工作

条件A = domain.com/favorite将显示“真”条件B = domain.com/any和domain.com/favorite/any将显示“假”

  <?php if ($this->uri->segment(1) == "favorite" && $this->uri->segment(2) == NULL) { echo "True"; }else{ echo "False"; } ?> 

您可能需要使用布尔值或|| 加上uri细分不适用于逗号。

在下面尝试此代码

if ($this->uri->segment(1) == "admin") {

  echo "Working";

} elseif ($this->uri->segment(1) || $this->uri->segment(2) == "admin/dashboard") {

    echo "False";

} else {

    echo "FALSE";

} 

要么

if ($this->uri->segment(1) == "admin") {

  echo "Working";

} elseif ($this->uri->segment(1) && $this->uri->segment(2) == "admin/dashboard") {

    echo "False";

} else {

    echo "FALSE";

} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM