WebMe
homeaboutportfolioservicescontact

WebMe - Website Design & Development

previous posts
archives
 

All resources published on this blog are free to use and redistribute. All we ask is that you keep any copyright notices and links to WebMe in your code. If you find something really useful we would appreciate you placing a link on your site to ours.

 
uk web design association Independent Web Developers Portal
This is a Carbon Neutral website Follow us on Twitter
All major credit cards accepted
Web Site Design BlogSubscribe to this Blog

Get Current Directory Function in PHP

Something that many people ask for is an extremely simple piece of code and that is "How do I get the current directory in PHP?" Well, we use a function to do this and the code is as follows:
function getDirectory() {
 $f = getcwd();
 return substr($f, strrpos($f, "/") + 1);
}
The PHP function getcwd() returns the current working directory and path. The following line simply strips the path and returns the name of the current directory. Instead of using getcwd() you can also use dirname(__FILE__) so the code could be rewritten as:
function getDirectory() {
 $f = dirname(__FILE__);
 return substr($f, strrpos($f, "/") + 1);
}

Labels: ,

Design web site media
0 Comments

 

info@webme.co.uk

copyright About UsServicesPortfolioDemoGet QuoteContact