A
A
Artqookie2010-11-20 21:28:36
PHP
Artqookie, 2010-11-20 21:28:36

include() function in PHP?

I just can’t figure it out ... Regardless of whether the following happens on the local machine or on a virtual server:
On the local server
Included: Not included: On the remote server Included: Not included: On the local server (file in the directory) Included: Not included:
<? include("functions.php"); ?>
<? include("http://localhost/functions.php"); ?>
<? include("functions.php"); ?>
<? include("http://site.ru/functions.php"); ?>
<? include("./dir/functions.php"); ?>

<? include("http://localhost/dir/functions.php"); ?>

On a remote server (a file in a directory)
Included: Not included: I read the manuals, it says that the includes only work non-locally. Here it turns out the other way around... I need to include exactly by the file address ( site.ru/functions.php), and not relative.
<? include("./dir/functions.php"); ?>
<? include("http://site.ru/dir/functions.php"); ?>

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
marcus, 2010-11-20
@Artqookie

In php.ini, the allow_url_include setting should be On. Just don't forget about safety.

A
Alexander, 2010-11-21
@akalend

do not want to include deleted files,
there are certainly alternative ways to solve the problem.
include only local files

F
frorff, 2013-11-13
@frorff

I use $_SERVER['DOCUMENT_ROOT']it and I don't know any troubles)))

H
Hotpilot, 2010-11-20
@Hotpilot

if there is no access to php.ini, then you can add a line to .htaccess - php_value allow_url_include On

G
gro, 2010-11-20
@gro

I read manuals, it is said that inclusions work only non-locally.

What kind of manuals are these?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question