Home >Backend Development >PHP Tutorial >Get the current class name, method name, function name magic constant in PHP (first time using markdown) markdown2 markdownextended zara's markdown

Get the current class name, method name, function name magic constant in PHP (first time using markdown) markdown2 markdownextended zara's markdown

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:53:011416browse

For an introduction to commonly used magic constants, you can directly refer to the PHP manual: Connection
Attached is a demo:

<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>

Output result:

<code>class:
test
test::output
output
function:

output
output</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces how to get the current class name, method name, and function name magic constant in PHP (first time using markdown), including markdown content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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