-4

url 1 - localhost/ocean/
url 2 - localhost/ocean/index.php

$file = basename($_SERVER['PHP_SELF']);
echo $file;

In both cases result is index.php and that's ok.

Now, I need to get parent folder of current file. So, in both cases result should be ocean.

Any help?

qadenza
  • 9,025
  • 18
  • 73
  • 126

1 Answers1

0

Use basename DIR

$file = basename(__DIR__);
echo $file; //ocean
Ramalingam Perumal
  • 1,367
  • 2
  • 17
  • 46