The .CO Era!

.CO TLD was opened today (20th July, 2010) for General Registrations at around 11:30PM (IST). More than 100000 domains were grabbed in First 25 minutes. If you were not able to grab a .com domain of your choice, now you have a chance to have a similar TLD – .CO.CO stands for – “Company”, “Corporation” … Read more

Page Generation Time (using PHP)

With this script you can display how much this Time this page has taken to load. <?php // Insert at the start of your document $time = round(microtime(), 3); // Insert at the end of your document $time2 = round(microtime(), 3); $generation = $time2 – $time; echo “This page took $generation seconds to render”; ?>

Fetching data from a Page (data between Tags) using PHP

You can fetch data from a webpage by using this script. It is useful when you need to fetch data like Stock Rates on your site. Like if you want to fetch data between span tags. <?php // retrieve htmltagcontent tag contents function get_htmltagcontent($file){ $h1tags = preg_match_all(‘/(<span>)(.*)(</span>)/ismU’,$file,$patterns); $res = array(); array_push($res,$patterns[2]); array_push($res,count($patterns[2])); return $res; } … Read more

Get Title of a Webpage using PHP – 3

<?php function getTitle($url) { $fh = fopen($url, “r”); $str = fread($fh, 5000); fclose($fh); $str2 = strtolower($str); $start = strpos($str2, “<title>”)+7; $len   = strpos($str2, “</title>”) – $start; return substr($str, $start, $len); } ?>

Get Title of a Webpage using PHP – 2

<?php $url=”http://example.com”; echo getTitle($url); function get_page_title($url) { if( !($data = file_get_contents($url)) ) return false; if( preg_match(“#<title>(.+)</title>#iU”, $data, $t))  { return trim($t[1]); } else { return false; } } ?>

Retrieve Current Page URL using PHP

<?php function curPageURL() { $pageURL = ‘http’; if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;} $pageURL .= “://”; if ($_SERVER[“SERVER_PORT”] != “80”) { $pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”]; } else { $pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”]; } return $pageURL; } ?> <?php echo curPageURL(); ?>

Retrieving URL Query Part

<?php function urlQUERY($url) { $url_data = parse_url ($url); if (!$url_data) return FALSE; $path =”; $query =”; if  (isset( $url_data[‘path’])) $path .=  $url_data[‘path’]; if  (isset( $url_data[‘query’])) $query .=  ‘?’ .$url_data[‘query’]; echo “$path $query “; } $url=”Enter Your URL”; urlQUERY($url)); ?>

Retrieving Page Name

By using the following script you can retrieve a page name. <?php function curPageName() { return substr($_SERVER[“SCRIPT_NAME”],strrpos($_SERVER[“SCRIPT_NAME”],”/”)+1); } echo “The current page name is “.curPageName(); ?>