All In One Script
MENU

Get current URL in JavaScript?

by 5:30:00 AM
undefined
Get current URL in JavaScript? I am using jQuery. How do I get the path of the current URL and assign it to a variable? Example URL: http://localhost/menuname.de?foo=bar&number=0 Answer: To get the path, you can use: var pathname = window.location.pathname; // Returns path only var url = window.location.href; // Returns full URL http://stackoverflow.com/questions/406192/get-current-url-in-javascript

Modify the URL without reloading the page

by 3:18:00 AM
undefined
Modify the URL without reloading the page Is there any way I can modify the URL of the current page without reloading the page? I would like to access the portion before the # hash if possible. I only need to change the portion after the domain, so its not like I'm violating cross-domain policies. window.location.href = "www.mysite.com/page2.php"; // sadly this reloads Answer: This can now be done in Chrome, Safari, FF4+, and IE10pp4+! See this question's answer for more info: Updating address bar with new URL without

Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to “Allow” the application)

by 5:00:00 AM
undefined
Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to “Allow” the application) I'm working on a CMS that fetches a user's profile image from their Facebook URL (that is, http://facebook.com/users_unique_url). How can I accomplish this? Is there a Faceboook API call that fetches a user's profile image URL without the user needing to Allow the application? Answer: Simply fetch the data through this URL: http://graph.facebook.com/userid_here/picture Replace userid_here with id of the user you want to get the photo of. You can

How to post data in PHP using file_get_contents?

by 4:49:00 AM
undefined
How to post data in PHP using file_get_contents? I'm using PHP's function file_get_contents() to fetch contents of a URL and then I process headers through the variable $http_response_header. Now the problem is that some of the URLs need some data to be posted to the URL (for example, login pages). How do I do that? I realize using stream_context I may be able to do that but I am not entirely clear. Thanks. Answer: Sending an HTTP POST request using file_get_contents is not that hard, actually : as

Saving image from PHP URL

by 4:47:00 AM
undefined
Saving image from PHP URL I need to save an image from a PHP URL to my PC. Let's say I have a page, http://example.com/image.php, holding a single "flower" image, nothing else. How can I save this image from the URL with a new name (using PHP)? Answer: If you have allow_url_fopen set to true: $url = 'http://example.com/image.php'; $img = '/my/folder/flower.gif'; file_put_contents($img, file_get_contents($url)); Else use cURL: $ch = curl_init('http://example.com/image.php'); $fp = fopen('/my/folder/flower.gif', 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); source

How to Get Domain Name from URL in PHP

by 12:49:00 AM
undefined
How to Get Domain Name from URL in PHP Parse domain name from URL is used in many cases in the web project. In this short tutorial, we’ll provide a simple code snippet to get domain name from URL in PHP. Using our example script, you’ll be able to extract only the domain name from any type of URL. All PHP code are group together in getDomain() function. The $url param should be passed to getDomain() function, from which you want to get the domain name. getDomain() function returns

Get current Domain URL in PHP

by 4:25:00 AM
undefined
Get current Domain URL in PHP I have my site on server http://www.myserver.uk.com For this i have two domain: http://one.com and http://two.com i would like get with PHP current domain, but if I use $_SERVER['HTTP_HOST'] then this show me myserver.uk.com instead of: one.com or two.com How can i get domain, not the server name? I have PHP version 5.2 Answer : try using this: $_SERVER['SERVER_NAME'] EDIT: apache_request_headers() or parse $_SERVER['REQUEST_URI']

How to get current page URL in PHP

by 4:19:00 AM
undefined
How to get current page URL in PHP get url in PHP function here Use the PHP $_SERVER Superglobal Variable You can use the $_SERVER built-in variable to get the current page URL in PHP. The $_SERVER is a superglobal variable, which means it is always available in all scopes. Also if you want full URL of the page you'll need to check the scheme name (or protocol), whether it is http  or  https  as shown in the example below: <?php $uri = $_SERVER['REQUEST_URI']; echo $uri; // Outputs:

Remove .php extension (explicitly written) for friendly URL

by 9:52:00 PM
undefined
Remove .php extension (explicitly written) for friendly URL htaccess to remove the .php extension of my site's files. RewriteEngine on RewriteBase / RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ $1.php [L,QSA] Now, if I go to my site www.mysite.com/home works fine, it redirects to home.php but the URL is still friendly. But if I write this URL: www.mysite.com/home.php The home.php is served, and the URL is not friendly. How can I avoid this behavior? I want that if the user writes www.mysite.com/home.php,

Instagram