php-doc-en/reference/phar/Phar/running.xml

94 lines
2.6 KiB
XML
Raw Permalink Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="phar.running" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Phar::running</refname>
<refpurpose>Returns the full path on disk or full phar URL to the currently executing Phar archive</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <modifier>static</modifier> <type>string</type><methodname>Phar::running</methodname>
<methodparam choice="opt"><type>bool</type><parameter>returnPhar</parameter><initializer>&true;</initializer></methodparam>
</methodsynopsis>
<para>
Returns the full path to the running phar archive. This is intended for use much
like the <literal>__FILE__</literal> magic constant, and only has effect inside
an executing phar archive.
</para>
<para>
Inside the stub of an archive, <function>Phar::running</function> returns
<literal>&quot;&quot;</literal>. Simply use <constant>__FILE__</constant>
to access the current running phar inside a stub.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>returnPhar</parameter></term>
<listitem>
<para>
If &false;, the full path on disk to the phar
archive is returned. If &true;, a full phar URL is returned.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the filename if valid, empty string otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>Phar::running</function> example</title>
<para>
For the following example, assume the phar archive is located
at <literal>/path/to/phar/my.phar</literal>.
</para>
<programlisting role="php">
<![CDATA[
<?php
$a = Phar::running(); // $a is "phar:///path/to/my.phar"
$b = Phar::running(false); // $b is "/path/to/my.phar"
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->