开发者

included php file to know it's file name?

开发者 https://www.devze.com 2023-02-07 01:10 出处:网络
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 fil

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

精彩评论

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