Jamit Software Forum
Welcome, Guest. Please login or register.
August 04, 2021, 07:59:45 pm

Login with username, password and session length
Search:     Advanced search
May 5th, 2010 - Jamit Software Launches the Market!
3,080 Posts in 791 Topics by 1,790,331 Members
Latest Member: RamiroRok
* Home Help Search Login Register
+  Jamit Software Forum
|-+  Jamit Job Board Customers
| |-+  User-to-User Support
| | |-+  Current Page URL
« previous next »
Pages: [1] Print
Author Topic: Current Page URL  (Read 4753 times)
szabcsee
Jammers
Hero Member
*
Posts: 115


« on: March 01, 2011, 11:55:17 am »

Hello,

What is the PHP tag for the current page's URL?

I'm building my own social media sharer bar and would like to just grab the current URL with the php tag instead of using javascript.
Can someone help?

Thank you.

« Last Edit: March 01, 2011, 12:59:17 pm by szabcsee » Logged
Peter
Administrator
Hero Member
*****
Posts: 248



« Reply #1 on: March 01, 2011, 01:05:36 pm »

Code:
<?php

function selfURL() {
$pageURL "http";
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"$pageURL .= "s";
$pageURL .= "://"$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
return $pageURL;
}

// use this when you need to print the page URL
echo selfURL();

?>

« Last Edit: April 05, 2011, 01:48:36 am by Peter » Logged

SECURE your site BEFORE you wish you had! Use plugins by COLOSSAL MIND!
szabcsee
Jammers
Hero Member
*
Posts: 115


« Reply #2 on: March 02, 2011, 12:32:48 pm »

Code:

<?php

function selfURL() {
$pageURL "http";
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"$pageURL .= "s";
$pageURL .= "://"$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
return $pageURL;
}

// use this when you need to print the page URL
echo selfURL();

?>

Thanks for the help Steve
do i need to include an echo selfURL at the end so it displays it or the return should do the trick? Because currently it is not working for me.
« Last Edit: April 05, 2011, 01:48:02 am by Peter » Logged
szabcsee
Jammers
Hero Member
*
Posts: 115


« Reply #3 on: March 08, 2011, 12:26:57 pm »

finally I solved the issue with Javascript. You can check out the result on the <a href="http://www.lingojob.com" title="külföldi munka">lingojob</a> Job details pages.
Logged
Peter
Administrator
Hero Member
*****
Posts: 248



« Reply #4 on: March 08, 2011, 01:47:24 pm »

Code:
<?php

echo selfURL();

?>

Logged

SECURE your site BEFORE you wish you had! Use plugins by COLOSSAL MIND!
szabcsee
Jammers
Hero Member
*
Posts: 115


« Reply #5 on: March 08, 2011, 01:57:28 pm »

Thanks Peter.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.026 seconds with 17 queries.