-5

I'm using this code to assign to the html tag the current folder's name

 <title><?php echo basename(__DIR__); ?></title>

what if I also wanted to include the parent folder's name in the title, so that the title would look something like "parentfolder-currentfolder"? Thanks!

brunogermain
  • 51
  • 1
  • 6

2 Answers2

0

Try like this:

<?php echo basename(dirname(__DIR__))."-".basename(__DIR__); ?>
Thamilhan
  • 13,040
  • 5
  • 37
  • 59
0

You can use realpath() to get where you want:

echo basename(realpath(__DIR__.'/../'));
pmayer
  • 341
  • 2
  • 13