Tuesday, June 7, 2011

Get web server application folder name WAMP LAMP

Let say you have a web application like wordpress in your localhost web server (WAMP)
The wordpress name is 'wordpressasipo'

Thus, the path to these is
C:\wamp\www\wordpressasipo

While in localhost it will be
http://localhost:80/wordpressasipo

The problem here is how the get the 'application name' (which is wordpressasipo) dynamically
Means even after you change the folder name (into wordpressasipo1 for example) it will still work

Here is the solution, quite usefull and I cant get this in quick googling

basename( realpath('.'));

Thus, if your application was in C:\wamp\www\wordpressasipo will return string wordpressasipo