Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 编码点火器条件函数_Php_Codeigniter - Fatal编程技术网

Php 编码点火器条件函数

Php 编码点火器条件函数,php,codeigniter,Php,Codeigniter,我使用codeigniter作为一个框架。 首先,我使用: public function edit_ads_wait($id) { $where["user"]=$this->session->userdata("userid"); $where["id"]=$id; $where["state"]=2; $info=$this->base->get_where_row("advertisement",$where); if($info)

我使用codeigniter作为一个框架。 首先,我使用:

public function edit_ads_wait($id)
{
   $where["user"]=$this->session->userdata("userid");
   $where["id"]=$id;
   $where["state"]=2;
   $info=$this->base->get_where_row("advertisement",$where);
   if($info) // if $info isset
   {
        $where_cat["deleted"]=0;
        $data["info"]=$info;
        $data["category"]=$this->base->get_where("category",$where_cat,$order);
        $data["region"]=$this->base->get("region");
        $this->userskin->loadview("user/ads/edit_ads",$data);

   }else // if $info is not set
    {
        $this->clear_session();
    }
}
当我执行edit_ads_wait函数(其中设置了$info)时,它还运行clear_session()函数,我的会话被清除

清除会话是

function clear_session()
{
     foreach ($this->session->all_userdata() as $key=>$val)
    {

          if(strlen($key)>=20)
          {  
            $this->session->unset_userdata($key);
          }
            //print_r($key);
    }
}

请帮帮我…

如果是的话,我猜您使用的是“视图”内部的功能,而不是“控制器”

快速修复方法:尝试添加
exit()
if
条件的末尾,在
else
之前

或者,如果您的函数在控制器类中,请确保该类如下所示

例如:如果控制器文件名为
example.php

    <?php
       class Example extends CI_Controller {
        //your constructor
        function exmple() {
          parent::__construct();
       // you can load libraries and helpers here
        }

 // your other functions

      }
  ?>

您能试试这个吗:

  if $info is an array then:
      if(isset($info) && !empty($info)) 

  if $info is a single value then:
      if(isset($info) && $info != '')

犯错误请再解释一遍?当我在codeigniter中执行edit_ads_wait函数并在$info变量中设置值,但执行$this->clear_session()时,请原谅;而且我的会话已丢失请确保您的
$info
不是
null、flase、empty
。尝试
var\u转储($info)
.tanks很多我确定并检查了它,但问题没有解决谢谢你它是真的我尝试了它,但我不知道为什么在隐藏执行清除会话()中条件为真时