Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Gaining URL through php?

Featured Replies

Hey I'm attempting to use the facebook like button integration for my website the problem is I need to put the current page being displayed's URL into the code to allow the facebook plugin to link to that page when clicked by a user, but as the page is being created dynamically I can't just type the URL in. How would I go about putting the current page's URL into the code when the user clicks the button? I don't want to just grab the contents of the URL box as this may allow users to change the content of it and cause problems? Thanks.

 

Code:


<iframe src="http://www.facebook.com/plugins/like.php?href=YOUR_URL"
  scrolling="no" frameborder="0"
  style="border:none; width:450px; height:80px">
</iframe>

  • Author

If you're after the full URL of the current page including the entire querystring use:

$_SERVER['REQUEST_URI'];

 

I pretty much just need the contents of the URL bar. So it can be linked to from facebook.

I pretty much just need the contents of the URL bar. So it can be linked to from facebook.

 

If you place information after the .php? like so... www.example.com/page.php?id=100

 

You can use the following...

 

$id = $_GET['id'];

 

If the page may at one point not have any information after the .php? add an "isset" to the GET (good idea to do this anyway for good practice)

Edited by Alluziion

as posted above use $_SERVER['REQUEST_URI']

 

or what about javascript...

 

<script type="text/javascript">
document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + window.location + '" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>');
</script>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.