<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php __class__ - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/php-__class__/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/php-__class__/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 01 Aug 2022 09:30:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>php __class__ - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/php-__class__/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What are Magic Constants in PHP ?</title>
		<link>https://www.wikitechy.com/interview-questions/php/what-are-magic-constants-in-php/</link>
					<comments>https://www.wikitechy.com/interview-questions/php/what-are-magic-constants-in-php/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Mon, 01 Aug 2022 09:09:07 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[default constant in php]]></category>
		<category><![CDATA[define and constant in php]]></category>
		<category><![CDATA[magic constant]]></category>
		<category><![CDATA[magic constant c++]]></category>
		<category><![CDATA[magic constants in php]]></category>
		<category><![CDATA[php __class__]]></category>
		<category><![CDATA[php __file__]]></category>
		<category><![CDATA[undefined constant php]]></category>
		<category><![CDATA[what is a constant in php]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=4535</guid>

					<description><![CDATA[In PHP magic constants are the predefined constants which is used on the basis of their use. Constants are created by various extensions and there are nine magic constants in the PHP and all of the constant resolved at the compile-time, not like the regular constant which is resolved at run time. In this there [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">In PHP magic constants are the predefined constants which is used on the basis of their use.</li>
<li style="text-align: justify;">Constants are created by various extensions and there are nine magic constants in the PHP and all of the constant resolved at the compile-time, not like the regular constant which is resolved at run time.</li>
<li style="text-align: justify;">In this there are eight magic constants which start and end with double underscores (__), they are.
<ul>
<li>__line__</li>
<li>__file__</li>
<li>__dir__</li>
<li>__function__</li>
<li>__class__</li>
<li>__method__</li>
<li>__namespace__</li>
<li>__trait__</li>
</ul>
</li>
</ul>
<h2 id="__line__" style="text-align: justify;">__line__</h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the current line number of the file.</li>
<li>In our program file if we use this magic constant somewhere then this constant will display the line number during compile time.</li>
</ul>
<h3 id="syntax" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">         __line__</code></pre> </div>
<h2 id="__file__" style="text-align: justify;">__file__</h2>
<ul style="text-align: justify;">
<li>This type of magic constant return the full path of the executed file with the name of the file.</li>
</ul>
<h3 id="syntax-2" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">         __file__</code></pre> </div>
<h2 id="__dir__" style="text-align: justify;">__dir__</h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the directory of the executed file.</li>
</ul>
<h3 id="syntax-3" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">          __dir__</code></pre> </div>
<h2 id="__function__"><span lang="EN-US" style="font-size: 16pt; font-family: 'Segoe UI', sans-serif; color: #000000; letter-spacing: 0.1pt;">__function__</span></h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the name of the function where it is included.</li>
</ul>
<h3 id="syntax-4" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">         __function__</code></pre> </div>
<h2 id="__class__"><span lang="EN-US" style="font-size: 16pt; font-family: 'Segoe UI', sans-serif; color: #000000; letter-spacing: 0.1pt;">__class__</span></h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the name of the class where it is included.</li>
</ul>
<h3 id="syntax-5" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">__class__</code></pre> </div>
<h2 id="__method__" style="text-align: justify;">__method__</h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the method name where it is included.</li>
</ul>
<h3 id="syntax-6" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">       __method__</code></pre> </div>
<h2 id="__namespace__" style="text-align: justify;">__namespace__</h2>
<p style="text-align: justify;">This type of magic constant returns the current namespace where it is included.</p>
<h3 id="syntax-7" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">       __namespace__</code></pre> </div>
<h2 id="__trait__" style="text-align: justify;">__trait__</h2>
<ul style="text-align: justify;">
<li>This type of magic constant returns the trait name where it is included.</li>
</ul>
<h3 id="syntax-8" style="text-align: justify;"><strong>Syntax</strong></h3>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-php code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-php code-embed-code">  __trait__</code></pre> </div>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/php/what-are-magic-constants-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
