Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get dir name

Posted on 2002-04-16
5
Medium Priority
?
323 Views
Last Modified: 2008-02-26
What I want to get hold of is the name of the dir that a php script has run within, say the script is called index.php and is running in a dir called test,  what I want to do is get the name test and store it in a variable. how is this done

thanks kieran
0
Comment
Question by:kplonk
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:andriv
ID: 6944984
Try:
echo dirname($REMOTE_SERVER);
0
 
LVL 4

Accepted Solution

by:
lokeshv earned 40 total points
ID: 6944989
chekc Default variable


$SCRIPT_FILENAME  and parse it...

$chunks=explode("/",$SCRIPT_FILENAME);
$count=count($chunks)-1;
$dir_name=$chunks[$count];

Hope this helps..

Lk
0
 
LVL 5

Expert Comment

by:andriv
ID: 6945078
I gave you wrong enviroment variable should be:

echo dirname($REMOTE_PATH);
0
 

Author Comment

by:kplonk
ID: 6954790
Lovley job, just a small chang to the code and i can do exactly what i want.
0
 
LVL 4

Expert Comment

by:lokeshv
ID: 6955397
Thanks for A


Lk
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question