471,086 Members | 961 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

problem with 'include' and 'file_exists' function

+86
i encountered this problem:
"include('inc.php')" will work problely
but "include('./inc.php') doesn't work ..
both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'

my environment is win2003+iis+php5

how to fix it ?

sorry to my English

thanks to you.

:)

Nov 25 '06 #1
6 2671
"include('inc.php')" will work problely
>but "include('./inc.php') doesn't work ..
There are plenty of situations where this will happen. If a file
name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?
>both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'
include() uses include_path to search for files.
file_exists() doesn't.

>my environment is win2003+iis+php5

how to fix it ?
The fix may be to correct the "right" value. Don't think that!

Nov 25 '06 #2
+86

"Gordon Burditt д
"
thanks for your answer.
>
There are plenty of situations where this will happen. If a file
name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?
The dicrecory is named 'test'.There's no file name like './',All files
in it ara 'info.php' and 'inc.php', if the current working directory is
'test' when i browse 'info.php'?
In this case if the two way to include is different?

include() uses include_path to search for files.
file_exists() doesn't.
I never set include_path before using win2003 and the win2000 server
run well.
>
my environment is win2003+iis+php5

how to fix it ?

The fix may be to correct the "right" value. Don't think that!
I think you can tell me how to resolve this problem..thanks :)

Nov 25 '06 #3
>There are plenty of situations where this will happen. If a file
>name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?

The dicrecory is named 'test'.There's no file name like './',
One of the file names you passed to include() began with period slash.
The comma is punctuation in the sentence.
>All files
in it ara 'info.php' and 'inc.php', if the current working directory is
'test' when i browse 'info.php'?
If file_exists('inc.php') returns false, then the current working
directory is a directory that does NOT have an inc.php in it. On
the other hand, the directory the script is in apparently DOES have
an inc.php in it. include('inc.php') searches both places.
include('./inc.php') only searches the first one. Are you SURE you
know what the current working directory is when the script is
started?
>In this case if the two way to include is different?
Read the documentation on include(). If the file name begins with
period slash, fewer directories are searched.

include('inc.php') may search in a lot of places.
include ('./inc.php') may search in fewer places.
file_exists('inc.php') looks in ONE place.

>include() uses include_path to search for files.
file_exists() doesn't.

I never set include_path before using win2003 and the win2000 server
run well.
Are all the path names on win2000 and win2003 *EXACTLY* the same?

So what is the value of include_path? If you didn't set it, there's
a default value.
>my environment is win2003+iis+php5

how to fix it ?

The fix may be to correct the "right" value. Don't think that!

I think you can tell me how to resolve this problem..thanks :)
Print out the current working directory by calling getcwd() and echo
the value. Is it the value you thought it was?
Nov 25 '06 #4

+86 wrote:
i encountered this problem:
"include('inc.php')" will work problely
but "include('./inc.php') doesn't work ..
both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'

my environment is win2003+iis+php5

how to fix it ?

sorry to my English

thanks to you.

:)
Can you post output of this code:
$d = dir("./");
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();

It will show what you have in "./". Add it before include.

Nov 26 '06 #5
+86
Thanks to you .

I found this problem is caused by authority .

the server run well now but don't determined how did I rosolve this
problem..:(

Nov 27 '06 #6
+86 wrote:
Thanks to you .

I found this problem is caused by authority .

the server run well now but don't determined how did I rosolve this
problem..:(
You'll probably have to change the security info in your server. I
might suggest a Windows server admin newsgroup - they'll know a lot more
about how to do it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 27 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chann Becker | last post: by
1 post views Thread by Hinrich Specht | last post: by
4 posts views Thread by rcb845 | last post: by
2 posts views Thread by Disco Octopus | last post: by
3 posts views Thread by Gunnar G | last post: by
20 posts views Thread by Bob Sanderson | last post: by
10 posts views Thread by SoulIntruder | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.