Wednesday, July 16, 2008

Snippet 2: Email Sending Snippet for PHP with email validator

function shortenurl($url){
$length = strlen($url);
if($length > 45){
$length = $length - 30;
$first = substr($url, 0, -$length);
$last = substr($url, -15);
$newurl = $first."[ ... ]".$last;
return $newurl;
}else{
return $url;
}
}

$longurl = "http://www.google.com/search?hl=en&client=firefox-a&channel=s&rls=org.mozilla%3Aen-US%3Aofficial&hs=BCR&q=metacafe&btnG=Search";
$shorturl = shortenurl($longurl);
echo"$shorturl";
?>

Snippet 1: Auto Updating your Copyrights ( PHP )

Snippet for Auto Updating your Copyrights

function autoUpdatingCopyright($startYear){
// given start year (e.g. 2004)
$startYear = intval($startYear);
// current year (e.g. 2007)
$year = intval(date('Y'));
// is the current year greater than the
// given start year?
if ($year > $startYear)
return $startYear .'-'. $year;
else
return $startYear;
}

-
Here i am using a function for the year. When year changes then the year next to (C) must also change. This code helps in doing it automatically. It checks the system / server year and shows it on the page.

101 ? Whats all about this ?

Hi friends, bloggers, and programmers. I finally decided to make my own blog and got stuck to how to start. Then i decided to make 101 Programming snippets. I will start from the 1st snippets and upto 101 snippets will be available on this blog very soon. So everyone given an hand to make this a big success.
101Snippets starts counting from today.

I will be adding all programming snippets. It can be vb.net, c#, php, AJAX, JSP, JS, HTML, Flash, ASP.net, C, C++, JAVA & others