Get current URL in WordPress

Here’s a quick tips by which you can get the current page url in wordpress. Usually I used to use php super global variables to do that and I need some extra checking whether the host using secure url (SSL) or not. But now with this two lines of code I can do that easily and it works out of the box in wordpress.

global $wp;
$current_url = home_url(add_query_arg(array(), $wp->request));