I am trying to include a file from a url, however I get the following error thrown up.
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /Applications/MAMP/htdocs/diningtime/testsite/salims/index1.php on line 58
Warning: include(http://localhost/diningtime/templates/100/index.php): failed to open stream: no suitable wrapper could be found in /Applications/MAMP/htdocs/diningtime/testsite/salims/index1.php on line 58
Warning: include(): Failed opening 'http://localhost/diningtime/templates/100/index.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.4.4/lib/php') in /Applications/MAMP/htdocs/diningtime/testsite/salims/index1.php on line 58
Test
Just wondering if there is anyway around this?
My PHP include code is
<?php include "$location/index.php"; ?>
I appreciate your help on this.
You're using a full URL as you include path, which tells PHP to attempt to do an HTTP request to fetch that file. This is NOT how you do this. Unless that ...100/index.php
outputs PHP code, you are going to get some HTML or whatever as the include result, NOT the php code in the file. Remember - you're fetching via URL, which means it's an HTTP request, which means the webserver will EXECUTE that script and deliver its output, not simply serve up its source code.
There's no way for the webserver to tell that the HTTP request for that script is an include call from another PHP script on the same server. It could just as easily be a request for that script from some hacker hiding in Russia wanting to steal your source code. Do you want your source code visible to the world like this?
For local files, you should never use a full-blown url. it's hideously inefficient, and will no do what you want. why not simply have
include('/path/to/templates/100/index.php');
instead, which will be a local file-only request, with no HTTP stage included?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With