リフレクションクラスを使用せずにクラス内で定義された定数を取得することは可能ですか?リフレクションを使用せずにPHPクラス内の定数を取得する方法
<?php
class Test {
const URL = 'https://www.example.com';
public function get($constant)
{
return $constant;
}
}
$test = new Test();
$test->get('URL');
私は出力が「https://www.example.com」ですURL
の値、になりたい:
は、私はこのような何かをしたいです。しかし、今は実際の単語「URL」を返します。
[PHP Docs](http://www.php.net/manual)に示されているように、単純に 'Test :: URL'と同じくらい簡単です。 /en/language.oop5.constants.php) –