简体   繁体   English

未定义偏移:1

[英]Undefined offset:1

        $aa = Input::get('AccountOpeningDate' . $i);
        $dateinfo = explode("-", $aa);
        $testDay = Carbon::createFromDate($dateinfo[0], $dateinfo[1], 
        $dateinfo[2], 'UTC');
        $actualDate = $testDay->setTimezone('+6:00');

when I run this code then I get an output.But it cause an error that like the image below.当我运行此代码时,我得到一个输出。但它会导致如下图所示的错误。

在此处输入图片说明

ErrorException in MemberController.php line 532:
Undefined offset: 1
in MemberController.php line 532
at HandleExceptions->handleError('8', 'Undefined offset: 1', 'C:\xampp\htdocs\timf\app\Http\Controllers\MemberController.php', '532', array('id' => '4001-5088-0565', 'memberdata' => object(Member), 'somityDay' => object(Zone1), 'i' => '2', 'aa' => '', 'dateinfo' => array(''), 'testDay' => object(Carbon), 'actualDate' => object(Carbon), 'producttype' => '2', 'memberaccount' => object(Accountstable), 'valsa' => object(Product), 'AccNameSub' => 'MSSM', 'accnumber' => 'MSSM.4001-5088-0565', 'k' => '13', 'SavingSetup' => 

This code is written in laravel 5.1.这段代码是用 laravel 5.1 编写的。

    $aa = Input::get('AccountOpeningDate' . $i);

Here $aa has no data in case of any conditions.这里 $aa 在任何情况下都没有数据。 So the array $dateinfo remaining empty.所以数组 $dateinfo 仍然是空的。 I have fixed the problem by ensuring $aa data not empty.我通过确保 $aa 数据不为空来解决这个问题。 now the code is running well.现在代码运行良好。

您的第一行代码中可能缺少一个逗号。

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

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