I'm trying to include a PHP script which I'd like included in a folder 1 deep from the webroot. It is being triggered by a file 8 tiers deep into the site design. (*Adapting a Wordpress site with some server) . I'm using PHP 7.0.15
include('/Applications/MAMP/htdocs/thesite/GFScripts/'.$postid.'.php');
//WORKS BUT IS A SLOPPY WAY OF CODING, CORRECT?
include(__DIR__ . '/../thesite/GFScripts/'.$postid.'.php');
// Does not work
include(dirname(__FILE__) . '/../thesite/GFScripts/'.$postid.'.php');
// Does not work
I've tried working with various stackoverflow comments but no luck so far. My main reference has been PHP include file in webroot from file outside webroot
Thanks for any help. I realise I could leave it as is, and change the directory once the site goes live. Though I'd like to write it in the best way and also understand why it is not currently working.