Showing posts with label anil kumar. Show all posts
Showing posts with label anil kumar. Show all posts

Monday, July 20, 2009

Call the php file using javascript.

we can the call the php file in javascript following syntax:

<?php

//"ip.php" example- display user IP address on any page
header("content-type: application/x-javascript");
$serverIP=$_SERVER['REMOTE_ADDR'];
echo "document.write(\"Your IP address is: " . $serverIP . "\")";

?>

to call the php file in html file like

<script type="text/javascript" src="ip.php"></script>




Hope it will be helpful.

Anil Kumar Panigrahi

Wednesday, July 15, 2009

How to get the tiny url using php code?

The following php code will generate the tiny urls


<?php

function getTinyUrl($url)
{
$tinyurl = file_get_contents("http://tinyurl.com/
api-create.php?url={$url}");
return $tinyurl;
}

$url="http://www.awesome-gallery-blogspot.com";
echo getTinyUrl($url);

?>



It will gives the url : http://tinyurl.com/ldq9aq


This will be useful when we are trying to post our url in different blog.
If we want more impressions without knowing the url name then we can use this function.

Tuesday, July 14, 2009