including a script, which outside of webroot is easy: you will do the same as for the script, which is under the web root:
include '../myscript.php'; include '../library/myscript.php'; include dirname(__FILE__) . '/../library/myscript.php';
The one you prefer ;-) I would go for the latter, humanly, though.
Publishing to the script that outside the web court is not possible: the script cannot be serviced by Apache (Apache only does what is inside the root website).
So, the script cannot be accessed via HTTP; which means that it cannot be accessed from the browser.
But if you send a script to PHP that is inside webroot, and that the script includes another that is outside of webroot, then the code in this second file will be executed as the first script. This means that he will have access to the data $_POST - the data entered in the form.
source share