开发者

included php file to know it's file name?

lets assume i have include.php

which sometimes includes 1.php , 2.php , 3.php ....

i want a line of code , in each of the included files to know it's name (aka print 1.php if it is the included file) WITHOUT the need to modif开发者_如何学Goy include.php itself .

is it possible ?


Use the __FILE__ constant.

echo __FILE__;

See Also:

  • Get name of current PHP script in include file
  • PHP Get the current script file name


The following piece of code prints the current filename

echo basename(__FILE__);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜