1

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 modify include.php itself .

is it possible ?

Rami Dabain
  • 4,709
  • 12
  • 62
  • 106

2 Answers2

5

Use the __FILE__ constant.

echo __FILE__;

See Also:

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
3

The following piece of code prints the current filename

echo basename(__FILE__);
Kristoffer Sall-Storgaard
  • 10,576
  • 5
  • 36
  • 46