0

I want to get file name from URL in an included page for example in meta.php

I use basename(__FILE__) but I get 'meta.php'

how I can echo index.php in an included page??

<meta name="description" content="<?php 
if(isset($FILEDATA_LANG['page_'.basename(__FILE__).'_keywords'])){ echo 
$FILEDATA_LANG['page_'.basename(__FILE__).'_keywords']; }?>">
  • Is this question answer helpful, for your problem? https://stackoverflow.com/questions/5755241/how-to-echo-the-contents-of-one-page-in-another-page – sollekram Feb 22 '18 at 21:46

2 Answers2

1

This has been asked earlier and you could've found your answer within seconds of searching, however, here's a proper response:

Set a variable in your index.php or a definition, such as:

define("THIS_PAGE", __FILE__); or $thisPage = __FILE__;

Then in your file you're including (after this variable), simply use: <?php echo $thisPage; ?> or <?php echo THIS_PAGE; ?>. (Keep in mind to check if the variable is set (isset($thisPage)) or (defined("THIS_PAGE")).

Reference: Get filename of file which ran PHP include

Luicy
  • 23
  • 1
  • 14
-1

I'm trying by adding .basename($_SERVER['SCRIPT_FILENAME']). I Hope it would work when i publish this page