一般的に使用されるマジック定数の概要については、PHP マニュアル「接続」を直接参照してください。
デモを添付します:
<code><span><?php</span><span>/** * Created by PhpStorm. * User: yanfeng * Date: 2016/3/31 * Time: 13:28 */</span><span><span>function</span><span>output</span><span>()</span> {</span><span>echo</span><span>"function:<br>"</span>; <span>echo</span><span>__CLASS__</span> . <span>"<br>"</span>; <span>echo</span><span>__METHOD__</span> . <span>"<br>"</span>; <span>echo</span><span>__FUNCTION__</span> . <span>"<br>"</span>; } <span><span>class</span><span>test</span> {</span><span>static</span><span><span>function</span><span>output</span><span>()</span> {</span><span>echo</span><span>"class:<br>"</span>; <span>echo</span><span>__CLASS__</span> . <span>"<br>"</span>; <span>echo</span><span>__METHOD__</span> . <span>"<br>"</span>; <span>echo</span><span>__FUNCTION__</span> . <span>"<br>"</span>; output(); } } test::output();</code>
<code>class: test test::output output function: output output</code>