<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns the full path on disk or full phar URL to the currently executing Phar archive</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.offsetunset.html">Phar::offsetUnset</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.setalias.html">Phar::setAlias</a></div> <div class="up"><a href="class.phar.html">Phar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="phar.running" class="refentry"> <div class="refnamediv"> <h1 class="refname">Phar::running</h1> <p class="verinfo">(PHP >= 5.3.0, PECL phar >= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::running</span> — <span class="dc-title">Returns the full path on disk or full phar URL to the currently executing Phar archive</span></p> </div> <div class="refsect1 description" id="refsect1-phar.running-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">string</span> <span class="methodname"><strong>Phar::running</strong></span> ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$retphar</code><span class="initializer"> = true</span></span> ] )</div> <p class="para rdfs-comment"> Returns the full path to the running phar archive. This is intended for use much like the <em>__FILE__</em> magic constant, and only has effect inside an executing phar archive. </p> <p class="para"> Inside the stub of an archive, <span class="function"><strong>Phar::running()</strong></span> returns <em>""</em>. Simply use <strong><code>__FILE__</code></strong> to access the current running phar inside a stub. </p> </div> <div class="refsect1 parameters" id="refsect1-phar.running-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">retphar</code></em></span> <dd> <p class="para"> If <strong><code>FALSE</code></strong>, the full path on disk to the phar archive is returned. If <strong><code>TRUE</code></strong>, a full phar URL is returned. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-phar.running-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the filename if valid, empty string otherwise. </p> </div> <div class="refsect1 examples" id="refsect1-phar.running-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-695"> <p><strong>Example #1 A <span class="function"><strong>Phar::running()</strong></span> example</strong></p> <div class="example-contents"><p> For the following example, assume the phar archive is located at <em>/path/to/phar/my.phar</em>. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">running</span><span style="color: #007700">(); </span><span style="color: #FF8000">// $a is "phar:///path/to/my.phar"<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">running</span><span style="color: #007700">(</span><span style="color: #0000BB">false</span><span style="color: #007700">); </span><span style="color: #FF8000">// $b is "/path/to/my.phar"<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.offsetunset.html">Phar::offsetUnset</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.setalias.html">Phar::setAlias</a></div> <div class="up"><a href="class.phar.html">Phar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>