The use of constant function in PHP

PHP中文网
Release: 2023-03-12 14:02:02
Original
1670 people have browsed it
<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>;
Copy after login

Reference address:

The above is the detailed content of The use of constant function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!