Solved

How to get dir name

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

773 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