Accessing Php Code Outside Public_html Folder
I'm trying to setup a new website using Twitter bootstrap as the front-end and PHP as the code behind. The directory structure I'm using is as follows and fairly standard c:\xampp
Solution 1:
You should have a file, usually called "index.php", in the "public_html" directory. Then your web server rules (e.g. .htaccess or server configuration) points all requests (or perhaps, all requests that aren't for files that exist in "public_html") to that "public_html/index.php". This is usually the only PHP file under "public_html", but sometimes there may be multiple for different purposes (e.g. a different one for serving images).
From there you can include the rest of your code using relative paths, each of the following is equivalent (code in "public_html/index.php"):
include__DIR__ . '/../application/[application-code].php';
And:
include dirname(__DIR__) . '/application/[application-code].php';
Where "application-code" is an entry point to your application, often named something like "bootstrap.php".
Post a Comment for "Accessing Php Code Outside Public_html Folder"