It is possible to include remote files in PHP, as the documentation says:
If the " wrappers URL include " are enabled in PHP , It can
specify the file to be included using a URL (via HTTP or other
supported wrapper - see Supported Protocols and Wrappers for
a list of protocols) instead of a local path. If he
target server interprets the target file as PHP code, the
variables can be passed to the included file using a string of
request as used with HTTP GET. This is not, strictly speaking, what
same as having included the file and having inherited the scope of
variables of the parent file; the script is really being executed
on the remote server and the result is then included within the
local script.
For more specific details on the inclusion of HTML files you can see the PHP Manual information about it .
Anyway:
A.
If your file is on the same server, the way to include it is by referring to the path in which the file is located, as the Manual says:
The files are included based on the given path or, if
none is given, the include_path
specified. If the file is not
found in the include_path
, include will finally verify in the
own directory of the script that makes the call and in the directory of
current work, before failing. The include constructor will emit a
warning if you can not find a file, this is a
behavior different from that of require, which will emit an error
fatal ..
The path in this case refers to the path on the server, not to a URL path.
B.
If your file is on another server, I would not recommend never to include files from another server, you would have to modify the php.ini
setting allowing a dangerous access , which would be more expensive and insecure than copying said file on the server itself and include it by the normal way indicated in A .