Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

May 7, 2013

Get URL from address bar - PHP


Get URL from address bar - PHP

 The following code is used to get full url address by using php.

<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
?>

Notes:
 Here we are using 2 functions in php to get full url from address bar.
1. $_SERVER['HTTP_HOST']
2. $_SERVER['REQUEST_URI']
$_SERVER['HTTP_HOST'] - This function will show only server name.
$_SERVER['REQUEST_URI'] - This function will show you the path to file of your url.

 When you run $_SERVER['HTTP_HOST'];  for this website you'll get result "www.techniqzone.blogspot.in" only, no "http://" no "/Get URL from address bar - PHP"

<?php 
$server=$_SERVER['HTTP_HOST'];
echo $server;
?>

Output is "www.techniqzone.blogspot.in".

This script "$_SERVER['REQUEST_URI']" display the result like below.
no "http://" and no "www.techniqzone.blogspot.in

Example:

<?php
$request_url=$_SERVER['REQUEST_URI'];
echo $request_url;
?>

Output of $_SERVER['REQUEST_URI'] is "/Get URL from address bar - PHP"

If you want to get full URL from this site you, we have to use (.) to connect 2 functions together and create http:// by yourself.

<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
?>

Feb 10, 2013

Add Favicon Image to HTML


Add Favicon Image to HTML site


Favicon is an image (icons/png) associated with a Web page/Web site. This favicon image is shown in the address bar or in tabs.. This is for website identity.

The following code should be in style tag.

<link rel="icon" type="image/png" href="http://techniqzone.blogspot.in/favicon.png">

if the favicon image is .ico format, then follow the below code.
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
Once you have created a favicon.ico file, you simply upload it to the root directory and add these two lines of coding to your webpage, making sure they go into the <head> section of your coding.