vesper8 Posted November 16, 2006 Share Posted November 16, 2006 Hey all. My website is very dynamic and I reuse the same code in many different areas of it.I'm translating my site so it has both french and english and I want to re-use the same code but add conditionnals in my code so it displays text in the right language. The way I decided to do this was to simply check the parent folder.IE if parent directoryis /en/ then it will display in english and if parent directory is /fr/ it'll display in french.. you get the idea.But I don't know how to make comparisons on the parent directory based on the script's current location.And also.. would this also work if the folder I want to check is two folders down? IE if I'm /public_html/en/html/ <-- here and want to make a check on the /en/ could i still do it? and how would I ?thanks in advance Link to comment https://forums.phpfreaks.com/topic/27409-any-way-to-check-parent-directory-with-php/ Share on other sites More sharing options...
SharkBait Posted November 16, 2006 Share Posted November 16, 2006 [code=php:0] dirname('myscript.php') [/code] I believe will return the current directory of where the script is being executed from.Check this out: http://ca.php.net/manual/en/reserved.variables.phpThat should help :) Link to comment https://forums.phpfreaks.com/topic/27409-any-way-to-check-parent-directory-with-php/#findComment-125371 Share on other sites More sharing options...
vesper8 Posted November 16, 2006 Author Share Posted November 16, 2006 hey thanks ill check it out!!i also found getcwd() which sorta does the job.. but your solution might be even simpler.cheers! Link to comment https://forums.phpfreaks.com/topic/27409-any-way-to-check-parent-directory-with-php/#findComment-125374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.