Posts Tagged ‘current url’

Get the current path url in php

Written by pelister. Posted in PHP

Directory handling in PHP is pretty much the same and easier as in C. To fetch the current working directory in PHP – dirname( __FILE__ ) will do, but to fetch the current path url we need to rely on $_SERVER, which holds all the information like host name, currently executing script, protocol ( http or https ) and so on. You can find tons of manual on this $_SERVER, so I am not going to write another manual page for this PHP variable. I have written a function that will return the current path url as I did earlier with JQuery – ( get the path of executed JS file ).

fetching url

Here is the few lines of code written as a function so you can call wherever you want.

Techlister© - 2012