Solved

How to get dir name

Posted on 2002-04-16
5
303 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 10 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

680 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