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,581
  • 12
  • 59
  • 104

2 Answers2

5

Use the __FILE__ constant.

echo __FILE__;

See Also:

Community
  • 1
  • 1
Pekka
  • 431,103
  • 135
  • 960
  • 1,075
3

The following piece of code prints the current filename

echo basename(__FILE__);
Kristoffer Sall-Storgaard
  • 10,466
  • 5
  • 33
  • 46