codeigniter 遇到PHP错误严重性:警告消息:未定义的属性:标准类::$已取消

sg3maiej  于 2022-12-07  发布在  PHP
关注(0)|答案(1)|浏览(93)

我在运行PHP Code Igniter项目时收到此错误消息:
遇到PHP错误严重性:警告
消息:未定义的属性:标准类::$已取消
文件名:favicon.php
行号:38
回溯:
文件:C:\xampp\htdocs\迷你库存和销售管理系统\应用程序\视图\交易\可移植. php行:38功能:错误处理程序
文件:C:\xampp\htdocs\迷你库存和销售管理系统\应用程序\控制器\Search.php行:103功能:观
文件:C:\xampp\htdocs\迷你库存和销售管理系统\index.php行:315功能:要求一次(_O)

以下是发生错误的代码。

<?php foreach($allTransactions as $get): ?>
                <tr>
                    <th><?= $sn ?>.</th>
                    <td><a class="pointer vtr" title="Click to view receipt"><?= $get->ref ?></a></td>
                    <td><?= $get->quantity ?></td>
                    <td>&#8373;<?= number_format($get->totalMoneySpent, 2) ?></td>
                    <td>&#8373;<?= number_format($get->amountTendered, 2) ?></td>
                    <td>&#8373;<?= number_format($get->changeDue, 2) ?></td>
                    <td><?=  str_replace("_", " ", $get->modeOfPayment)?></td>
                    <td><?=$get->staffName?></td>
                    <td><?=$get->cust_name?> - <?=$get->cust_phone?> - <?=$get->cust_email?></td>
                    <td><?= date('jS M, Y h:ia', strtotime($get->transDate)) ?></td>
                    <td><?=$get->cancelled? 'Cancelled' : 'Completed'?></td>
                </tr>
                <?php $sn++; ?>
                <?php endforeach; ?>

文件:C:\xampp\htdocs\迷你库存和销售管理系统\应用程序\视图\交易\可转换. php行:38功能:错误处理程序
文件:C:\xampp\htdocs\迷你库存和销售管理系统\应用程序\控制器\搜索. php行:103功能:视图

public function transSearch()
  {
    $data['allTransactions'] = $this->transaction->transsearch($this->value);
    $data['sn'] = 1;

    $json['transTable'] = $data['allTransactions'] ? $this->load->view('transactions/transtable', $data, TRUE) : "No match found";

    //set final output
    $this->output->set_content_type('application/json')->set_output(json_encode($json));
  }

文件:C:小型库存和销售管理系统315功能:要求一次

require_once BASEPATH.'core/CodeIgniter.php';
wj8zmpe1

wj8zmpe11#

使用isset()函数检查属性是否有值

<td><?= isset($get->cancelled) ? 'Cancelled' : 'Completed' ?></td>

或者使用property_exists()函数来检查对象是否具有密钥。

<td><?= property_exists($get, 'cancelled') ? 'Cancelled' : 'Completed' ?></td>

相关问题