Get name of current file inside Phar archive

纵饮孤独 提交于 2019-12-11 13:02:48

问题


I'm currently learning about PHP archives (Phars) and I know that in PHP __FILE__ always is the absolute filename of the currently executing file.

But to which file does __FILE__ point to if the script is inside a Phar? Is it the absolute filename of the Phar itself, or the Phar-URL to the current script inside the Phar?

For example: If I have a Phar located at /path/to/my.phar which contains a stub script, and a PHP script located at phar:///path/to/my.phar/inside/inner.php. What would __FILE__ be in the stub and inner.php?


回答1:


You could have tried it yourself.

The short answer is that __FILE__ has the full path; it's

phar:///home/cweiske/Dev/test/phar/test.phar/path/to/foo.php

in my test case - see http://p.cweiske.de/172



来源:https://stackoverflow.com/questions/28438438/get-name-of-current-file-inside-phar-archive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!