Phar::running

(PHP 5 >= 5.3.0, PHP 7, PECL phar >= 2.0.0)

Phar::runningReturns the full path on disk or full phar URL to the currently executing Phar archive

说明

final public static Phar::running ([ bool $retphar = TRUE ] ) : string

Returns the full path to the running phar archive. This is intended for use much like the __FILE__ magic constant, and only has effect inside an executing phar archive.

Inside the stub of an archive, Phar::running() returns "". Simply use __FILE__ to access the current running phar inside a stub.

参数

retphar

If FALSE, the full path on disk to the phar archive is returned. If TRUE, a full phar URL is returned.

返回值

Returns the filename if valid, empty string otherwise.

范例

Example #1 A Phar::running() example

For the following example, assume the phar archive is located at /path/to/phar/my.phar.

<?php
$a 
Phar::running(); // $a is "phar:///path/to/my.phar"
$b Phar::running(false); // $b is "/path/to/my.phar"
?>

相关文章
php gnupg 函数 returns the currently active protocol for all operationsphp phar compresses the entire phar archive using gzip or bzip2 compressionphp phar compresses all files in the current phar archive using bzip2 compressionphp phar returns the number of entries files in the phar archivephp phar returns phar archive meta dataphp phar get the real path to the phar archive on diskphp phar return md5/sha1/sha256/sha512/openssl signature of a phar archivephp phar returns phar gz or phar bz2 if the entire phar archive is compressed .tar.gz/tar.bz and so on php phar returns true if the phar archive is based on the tar/phar/zip file format depending on the parameterphp phar returns true if the phar archive can be modifiedphp phar mount an external path or file to a virtual location within the phar archivephp phar returns the full path on disk or full phar url to the currently executing phar archivephp phar stop buffering write requests to the phar archive and save changes to diskphp phar uncompresses all files in the current phar archivephp phar completely remove a phar archive from disk and from memoryphp phardata convert a phar archive to a non executable tar or zip filephp phardata convert a non executable tar/zip archive to an executable phar archivephp pharfileinfo returns the actual size of the file with compression inside the phar archivephp reflectiongenerator gets the currently executing line of the generatorphp solrresponse returns the full url the request was sent to
关注编程学问公众号