如何在私有函数内部调用常量?

时间:2018-12-25 04:05:40

标签: php laravel-5

我正在尝试获取私有函数内部帮助文件中定义的常量。我的助手文件在app \ Helpers \ Report \中。这是我尝试的代码。但我收到以下错误消息:

Use of undefined constant CONDITION_A - assumed 'CONDITION_A' 

我做错了什么?

ReportHelper.php

namespace App\Helpers\Report;

class ReportHelper 
{
    const CONDITION_A = "A";
    const CONDITION_B = "B";

    .....
}

MyController

<?php
namespace App\Http\Controllers;

use App\Helpers\Report\ReportHelper;

class MyController extends Controller
{
    private function _test() {
        echo ReportHelper::CONDITION_A;
    }
}

0 个答案:

没有答案