Php 数组或变量在输入if/else语句时丢失值

Php 数组或变量在输入if/else语句时丢失值,php,laravel,Php,Laravel,下面是我为$list声明值的一些代码 $list['first_name'] = Request::input("first_name"); $list['last_name'] = Request::input("last_name"); 当我使用dd($list)时,它显示的值与我的 但当它进入这个if-else语句时 if($existing_customer) { $customer_id = $existi

下面是我为$list声明值的一些代码

$list['first_name']            = Request::input("first_name");
$list['last_name']             = Request::input("last_name");
当我使用dd($list)时,它显示的值与我的

但当它进入这个if-else语句时

if($existing_customer)
{
     $customer_id            = $existing_customer->customer_id;
}
else
{
    dd($list);
    $insert_customer["first_name"]     = ($list['first_name'] == "undefined" ? "John" : ucfirst($list['first_name']));
    $insert_customer["last_name"]      = ($list['last_name'] == "undefined" ? "Doe" : ucfirst($list['last_name']));
}
这是最新的

这是我的功能照片,如果可以的话。

公共函数导入_提交()
{
$data=Self::获取初始设置();
/*初始化和捕获数据*/
$shop\u id=$this->user\u info->shop\u id;
$SANDORM=Tbl_mlm_slot::where(“slot_no”,Request::input(“赞助商”)->where(“shop_id”,$shop_id)->value(“slot_id”);
$placement=Tbl_mlm_slot::where(“slot_no”,Request::input(“placement”)->where(“shop_id”,$shop_id)->value(“slot_id”);
/*定位数据*/
$slot_赞助商=$sponsor;
$slot_placement=$placement;
$slot_position=strtolower(请求::输入(“位置”);
/*时隙生成*/
$membership_package_id=请求::输入(“package_编号”);
/*如果现有客户需要,只需添加到插槽*/
如果(请求::输入(“创建日期”)=“未定义”)
{
$slot_date_created=日期(“Y-m-d h:i”);
}
其他的
{
$slot_date_created=date(“Y-m-d”),strottime(请求::输入(“date_created”);
}
$existing_customer=Tbl_customer::where(“shop_id”,$shop_id)->where(“email”,Request::input(“email”)->first();
$list['first_name']=请求::输入(“first_name”);
$list['last_name']=请求::输入(“last_name”);
$list['email']=请求::输入(“email”);
$list['slot_no']=请求::输入(“slot_no”);
$list['password']=请求::输入(“密码”);
$list['birth']=请求::输入(“birth”);
$list['contact']=请求::输入(“联系人号码”);
$list['gender']=请求::输入(“gender”);
dd($list);客户id;
}
其他的
{
dd($list);$value)
{
$insert_customer_address[“customer_id”]=$customer_id;
$insert_customer_address[“country_id”]=420;
$insert_customer_地址[“customer_state”]=“”;
$insert_customer_地址[“customer_city”]=“”;
$insert_customer_address[“customer_zipcode”]=”;
$insert_customer_address[“customer_street”]=请求::输入(“地址”);
$insert_customer_address[“purpose”]=$value;
$insert_客户_地址[“存档”]=0;
$insert_customer_address[“created_at”]=Carbon::now();
$insert_customer_address[“updated_at”]=Carbon::now();
Tbl_客户地址::insert($insert_客户地址);
}
}
}

我真的看不出哪里出错了,因为输入if/else语句的值变为null。

为什么不将代码放在文本中?对不起,先生,我的函数有点长,但我放在文本中的代码基本上是出错的地方。。。我想选择你的代码。复制它们。将它们粘贴到编辑器中。再次在编辑器中选择你的代码。按编辑器中的{}按钮,你会看到它工作正常,没有问题:)先生,有更新,所以如果你在同一个脚本实例中进行两个调试输出,一个直接在if之前,另一个在else分支中,你会得到两个不同的输出?您能否将调试输出的确切位置编辑为上述函数的完整代码,以便我们以1:1的比例看到您正在执行的内容?
public function import_submit()
{
    $data                       = Self::get_initial_settings();
    /* INITIALIZE AND CAPTURE DATA */
    $shop_id                    = $this->user_info->shop_id;
    $sponsor                    = Tbl_mlm_slot::where("slot_no", Request::input("sponsor"))->where("shop_id", $shop_id)->value("slot_id");
    $placement                  = Tbl_mlm_slot::where("slot_no", Request::input("placement"))->where("shop_id", $shop_id)->value("slot_id");

    /* POSITIONING DATA */
    $slot_sponsor               = $sponsor;
    $slot_placement             = $placement;
    $slot_position              = strtolower(Request::input("position"));


    /* SLOT GENERATION */
    $membership_package_id      = Request::input("package_number");


    /* JUST ADD TO SLOT IF EXISTING CUSTOMER */


    if(Request::input("date_created") == "undefined")
    {
        $slot_date_created      = date("Y-m-d h:i");
    }
    else
    {
        $slot_date_created      = date("Y-m-d", strtotime(Request::input("date_created")));
    }

    $existing_customer          = Tbl_customer::where("shop_id", $shop_id)->where("email", Request::input("email"))->first();

    $list['first_name']            = Request::input("first_name");
    $list['last_name']             = Request::input("last_name");
    $list['email']                 = Request::input("email");
    $list['slot_no']               = Request::input("slot_no");
    $list['password']              = Request::input("password");
    $list['birthday']              = Request::input("birthday");
    $list['contact']               = Request::input("contact_number");
    $list['gender']                = Request::input("gender");

    dd($list); <---- first run of the function, I put one here


    if($existing_customer)
    {
        $customer_id            = $existing_customer->customer_id;
    }
    else
    {
        dd($list); <--- for the second run of the function, to check what happens to my $list
        $insert_customer["shop_id"]        = $shop_id;
        $insert_customer["first_name"]     = ($list['first_name'] == "undefined" ? "John" : ucfirst($list['first_name']));
        $insert_customer["last_name"]      = ($list['last_name'] == "undefined" ? "Doe" : ucfirst($list['last_name']));

        $insert_customer["email"]          = ($list['email'] == "undefined" ? "dummy@gmail.com" : $list['email']);
        $insert_customer["ismlm"]          = 1;
        $insert_customer["mlm_username"]   = $list['slot_no'];
        $insert_customer["password"]       = ($list['password'] == "undefined" ? Crypt::encrypt(randomPassword()) : Crypt::encrypt($list['password']));
        $insert_customer["created_date"]   = $slot_date_created;
        $insert_customer["b_day"]          = date("Y-m-d", strtotime($list['birthday']));
        $insert_customer["birthday"]       = date("Y-m-d", strtotime($list['birthday']));
        $insert_customer["contact"]        = $list['contact'];
        $insert_customer["gender"]         = strtolower($list['gender']);

        $customer_id = Tbl_customer::insertGetId($insert_customer);

        /* Insert Customer Address */
        $address_purpose[0] = "permanent";
        $address_purpose[1] = "billing";
        $address_purpose[2] = "shipping";

        foreach ($address_purpose as $key => $value) 
        {
            $insert_customer_address["customer_id"] = $customer_id;
            $insert_customer_address["country_id"] = 420;
            $insert_customer_address["customer_state"] = "";
            $insert_customer_address["customer_city"] = "";
            $insert_customer_address["customer_zipcode"] = "";
            $insert_customer_address["customer_street"] = Request::input("address");
            $insert_customer_address["purpose"] = $value;
            $insert_customer_address["archived"] = 0;
            $insert_customer_address["created_at"] = Carbon::now();
            $insert_customer_address["updated_at"] = Carbon::now();

            Tbl_customer_address::insert($insert_customer_address);
        }
    }
}