Hi all,

On the the include_path php.net says:

"Using a . in the include path allows for relative includes as it
means the current directory. However, it is more efficient to
explicitly use include './file' than having PHP always check the
current directory for every include. "


While this does not state that starting every include with "./" is
equivalent to having an include_path that is ".", it does suggest
exactly that.

However, I tried this in the field, and came to a different
conclusion. (I included my experiment below.)

Is the idea that those two are equivalent wrong?
Am I doing something wrong?
Is something strange going on?

Can anyone clear this issue up for me?




The experiment:

On a machine where the include_path is ".", I had the following file structure:

- A.php
- B.php
- C.php
- file.php
- sub/includeA.php
- sub/includeB.php
- sub/includeC.php

The content of the files:


include 'file.php'



include './file.php'



include './../file.php'



echo "Included successfully!";



include '../A.php'



include '../B.php'



include '../C.php'


Now if you visit A.php or B.php the file will be included
successfully. Obviously, C.php fails to include anything.
includeA.php works all the same, but includeB.php can't find file.php.
includeC.php, on the other hand, finds it just fine.

This would suggest that include_path being "." means you can include
from the path of the current file, while starting your "./" means you
start looking from the current parh.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to