Solved

How to get dir name

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now