I'm trying to insert a file with a include
, but for some reason it doesn't work with the full URL.
This works:
<?php include 'menu.html' ?>
But this is not so:
<?php include 'http://domainname.com/menu.html' ?>
Any ideas?
PS: I understand the security hazard of doing this.
In order to include files remotely, you must set the directives
allow_url_include, allow_url_fopen
inon
thephp.ini
.From a security point of view, it's bad to do so, that's why it's usually disabled.
And try to include it like this:
Here you can see some reasons why it is not recommended: https://help.dreamhost.com/hc/en-us/articles/214205688-allow-url-include
It is possible to include remote files in PHP, as the documentation says :
For more specific details about including HTML files you can see the information in the PHP Manual about it .
In any case:
A.
If your file is on the same server, the way to include it is by referring to the path where the file is located, as the Manual says:
The path in this case refers to the path on the server, not a URL path.
b.
If your file is on another server, I would never recommend you to include files from another server, you would have to modify the configuration of
php.ini
allowing dangerous access , which would be more expensive and insecure than copying said file on the server itself and include it by default . normal pathway indicated in A.This should work
put it where the menu goes
Cheers
note: research more about curl for more option
The include does not work for remote files. It only includes from the same file system.