Jump to content

any way to check parent directory with php ?


vesper8

Recommended Posts

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
[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.php

That should help :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.