182x Posted July 26, 2007 Share Posted July 26, 2007 hey guys, I was reading a tutorial on PHP and it referes to absolute and relative paths I was just wondering is the following "../test/test2/test.php" classed as an absolute or relative path? The reason I ask is that I always thought it was a relative path but in the tutorial for jpgraph it states that only absolute paths can be used and the above style works. thanks. Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/ Share on other sites More sharing options...
nicelad_uk Posted July 26, 2007 Share Posted July 26, 2007 From what I understand thats a relative path, an absolute path would have the address in like http://www.yourhostname.com/path1/path2/path3.php. Relative path would be like /path1/path2/path3.php. Someone correct me if Im wrong though Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308245 Share on other sites More sharing options...
Crow Posted July 26, 2007 Share Posted July 26, 2007 Relative paths are paths relative to the file location: <?php include './lib/mysql.class'; ?> If the file is in /var/www then this becomes /var/www/lib/mysql.class If the file moves to /etc/website then this becomes /etc/website/lib/mysql.class Absolute paths are relative to the directory structure, and aren't affected by when the file moves: <?php include '/home/steve/bot/lib/mysql.class'; ?> No matter where the file is located this path is always /home/steve/bot/lib/mysql.class. -Steve Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308250 Share on other sites More sharing options...
182x Posted July 26, 2007 Author Share Posted July 26, 2007 Could this then lead to any problems that I have used a relative path? Although in testing it seems fine. Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308252 Share on other sites More sharing options...
Crow Posted July 26, 2007 Share Posted July 26, 2007 There shouldn't be any problems as long as you keep the paths correct. IE: If you move index.php you have to move the file you're pointing to also. -Steve Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308255 Share on other sites More sharing options...
182x Posted July 26, 2007 Author Share Posted July 26, 2007 Thanks, am I correct in assuming that the ".." in the path means go back back one directory? So if "../../" was used it means go back two directories? Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308260 Share on other sites More sharing options...
Crow Posted July 26, 2007 Share Posted July 26, 2007 Exactly (just as . is current directory) Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308286 Share on other sites More sharing options...
182x Posted July 26, 2007 Author Share Posted July 26, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/61907-solved-absolute-path/#findComment-308359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.