While this would depend on the actions of your code, what your doing is both correct and an acceptable practice. Using “require_once” the server will essentially treat the code in the required file as if it is part of the script on the originating file. Take a look through any of the big CMS apps (Wordpress, Drupal, etc) and you will see a string of includes and requires starting from the root index.php.
I have never heard of such functionality. Hardcoding is your only option as far as I know. You’d have to create a var that has the script name in it prior to including the other script.
Example:
<?php
$includingScript = $_SERVER['PHP_SELF'];
// Now functions.pp will know the name of the including script.
require('functions.php');
?>
I may be reading between the lines here, but it sounds as if you’re trying to prevent hotlinking/cross-including the file; this is often done by [FPHP]DEFINE[/FPHP]'ing a constant in your intended includer, and checking for it in the file to be included. (A variable would also accomplish the same thing)
Obviously this becomes less effective if you distribute your code, as it relies upon noone else knowing what constant you’ve defined.