If, within a php generated page (findmyfilename.php), I embed a JavaScript file (php_js.php) that uses php to generate its content, is there any way within php_js.php that I can find with php the name of the parent i.e. findmyfilename.php?
I have tried
$parentfile = $_SERVER['PHP_SELF'];
$parentfile = basename(__FILE__);
$parentfile = $_SERVER["SCRIPT_NAME"];
$parentfile = $_SERVER["REQUEST_URI"];
$parentfile = $_SERVER["SCRIPT_FILENAME"];
but these all return php_js.php.
I want to be able to generate the content of php_js.php depending upon the page that called it.
// findmyfilename.php
<!DOCTYPE html>
<html>
<head>
<title>Find my filename</title>
</head>
<body>
<script type="text/javascript" src="/scripts/php_js.php">
</body>
</html>