|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-11-15 17:35 UTC] pupeno at pupeno dot com
I'm requesting a page, the file that is called is index.php, but this file is a symlink from somewhere else. When I require a file from index.php, if there's no '..' (dots) on the path (a relative path, but not going back), the relative path is from where the original file is, but if there are '..' on the path, the relative path is from where the symlink is (although php identifies the script as the original file in the error message). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 14:00:01 2025 UTC |
I don't have a 'working' on line example to show you this and I don't have posibilities to do it right now, I'm sorry, but I'll try to show you here what I mean with an example. Let's supouse I have one script in this file /var/php/scripts/index.php and I have a symlink to that file like this /var/www/htdocs/index.php -> ../../php/scripts/index.php and this file contains the following: <?php require("dir/include.php"); require("../dir/include.php"); ?> When I run it, for require("dir/include.php"); it tryes to include /var/php/scripts/dir/include.php (the relative path from the original location of the file) but for require("../dir/include.php"); it tryes to icnlude /var/www/dir/include.php (real path for /var/www/htdocs/../dir/include.php) (it is resolving the relative path from the symlink and not the original file). I'm not sure with behaviour is the right one, but this mix is not the right one for sure, I think. I hope it helps, if you need more help, just contact me. Thank you.I think you don't understand me. In which directory are you in when executing a script ? The directory where the symlink is or the directory where the original file is ? Well, depending if the path goes backwards or not (with two dots '..') the path to calculate a relative path is one or the other. Do you understand me ? require("dir/include.php"); loads /var/php/scripts/dir/include.php while require("../dir/include.php"); loads /var/www/dir/include.php. They're calculated from diferet base paths, please, take a look at the example I gave, exactly at the paths, there is where the problem is. One path is calculated from where the file is, and the other path is calculated from where the symlink is, and the only diference between both paths is the '..'. To give you a better example. Original script: /var/php/scripts/index.php Symlink: /var/www/htdocs/index.php -> ../../php/scripts/index.php Acording to what you say (which makes sense to me) this two lines should include the same file: require("include.php"); require("../scripts/include.php"); right ? well, the first one fill succesfully include /var/php/scripts/include.php while the second one will include /var/www/scripts/include.php (because this path instead of being /var/php/scripts/../scripts/include.php is /var/www/htdocs/../scripts/include.php) It is resolved from the location of the symlink and not the original file.