<span style="color: #0000ff"><span class="refname"># constant — <span class="dc-title">返回一个常量的值</span></span><br>interface</span><span style="color: #000000"> Test{ </span><span style="color: #0000ff">const</span> BAR = 'foobar'<span style="color: #000000">; } </span><span style="color: #0000ff">class</span><span style="color: #000000"> Foo{ </span><span style="color: #0000ff">const</span> BAR = 'foo_bar'<span style="color: #000000">; } </span><span style="color: #800080">$test</span> = 'BAR'<span style="color: #000000">; </span><span style="color: #0000ff">echo</span> <span style="color: #008080">constant</span>('Test::' . <span style="color: #800080">$test</span><span style="color: #000000">); </span><span style="color: #0000ff">echo</span> <span style="color: #ff00ff">PHP_EOL</span><span style="color: #000000">; </span><span style="color: #0000ff">echo</span> 'Foo::' . <span style="color: #800080">$test</span>;
#參考位址:
以上是PHP中constant函數的使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!