Solved

How to get dir name

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

863 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

19 Experts available now in Live!

Get 1:1 Help Now