-1

I have a PHP file called particular.php. I have included family.php inside particular.php with include function.

So when I do $_SERVER["PHP_SELF"] I get particular.php. I want to get file name family.php.

I have several files that needs to redirect to included file automatically. For that I need to get included files name rather than main file name.

tapaljor
  • 237
  • 1
  • 6
  • 21
  • $_SERVER["PHP_SELF"] tells only about current PHP file getting executed no matter what you are including in it. – d.coder Apr 25 '18 at 06:14
  • Why you want `family.php`? What is your next action if you get family.php...? – d.coder Apr 25 '18 at 06:15
  • Possible duplicate of [Get the current script file name](https://stackoverflow.com/questions/4221333/get-the-current-script-file-name) – makadev Apr 25 '18 at 06:18
  • 1
    Don't use `PHP_SELF`, use `__FILE__` to get the current processed file from within a php file. This and similar Question where already answered several times. Checkout [this](https://stackoverflow.com/a/4221345/3828957) for example. – makadev Apr 25 '18 at 06:21

1 Answers1

1

There is a PHP function called get_included_files(). This stores all the included files.

tapaljor
  • 237
  • 1
  • 6
  • 21