No. Using ./
at the start of your include file name forces it to be searched from the "current directory" as set by your web server (most probably the directory of the initial script, or the DocumentRoot, depending on the webserver).
The way to get the behaviour you want depends on the value of your include_path
(which can be modified with set_include_path()
if necessary).
From the documentation for include()
:
Files for including are first looked for in each include_path entry
relative to the current working directory, and then in the directory of current script. E.g. if your include_path
is libraries
, current working directory is /www/
, you included include/a.php
and there is include "b.php
" in that file, b.php is first looked in /www/libraries/
and then in /www/include/
. If filename begins with ./
or ../
, it is looked for only in the current working directory or parent of the current working directory, respectively.
So, if there's no chance that the filename will be found in another directory in the include_path
first, you could use include('apple.php')
.
If there is a possibility that apple.php exists elsewhere, and you want the copy in this folder to be used first, you could either use Matthew's suggestion, and
include(dirname(__FILE__).'/apple.php');
or, if you have many files to include from the current directory:
old_include_path = set_include_path(dirname(__FILE__));
include('apple.php');
include('orange.php');
include('peach.php');
include('pear.php');
set_include_path(old_include_path);