RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

Get Current Page URL With PHP

The following function permits you to get the current page (or permalink) URL with PHP. Not unlike regular expression variations, there are numerous methods to return the current URL... so expect this function to evolve over time.

1
<?php 
2
/*
3
 Get Current URL With PHP
4
 http://www.beliefmedia.com/code/php-snippets/current-url-php
5
*/
6
 
7
function beliefmedia_get_url() {
8
 
9
  $url = ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) ? 'https' : 'http';
10
  $url .= '://' . $_SERVER['SERVER_NAME'];
11
  $url .= in_array( $_SERVER['SERVER_PORT'], array( '80', '443' ) ) ? '' : ":" . $_SERVER['SERVER_PORT'];
12
  $url .= $_SERVER['REQUEST_URI'];
13
 
14
 return $url;
15
}
16
 
17
/* Usage */
18
echo beliefmedia_get_url();

If used on this page, the function would return http://www.beliefmedia.com/code/php-snippets/current-url-php.

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment