FAQ: What are follow and nofollow links?

Follow and nofollow links refer to a tag that can be placed in the linking (anchor) code of your website.  It usually comes in the form of the “rel” attribute.  It looks something like this:

<a href=”http://www.jtgraphic.net” rel=”nofollow”>jtGraphicn.net</a>

Why are these attributes on links important?  They help organize the internet and give relevancy to websites that deserve it and don’t give relevancy to websites that don’t.  Google and other search engines use this information in the “rel” attribute to tabulate the score, or authority, that one website gives to another.

Getting a large number of follow links increases the relevancy of your website for the keywords relevant to the link.  Usually the “anchor text” or text between the <a>…</a> tags is what most directly contributes to keyword relevancy.  When websites build in areas where users can submit their own information, they tend to use nofollow links to reduce spam related link follows.  Simply neglecting to include a “rel” attribute makes a link a “follow” link.

You can get follow links many places, including top comments areas on blogs, guest posting, press coverage, and article submission sites.  There are a ton of other places to get follow links as well.  What do you find is the best way to get follow links?

PHP Function Friday: function

So, I’ve decided to start including a new post every Friday – kind of as a discipline thing. I’m going to write a post on a PHP function every Friday. I’m not just going to regurgitate the post in the official PHP manual, but I’m going to list my experience with it along with some creative ways to use it.

With out any further adieu, I’m posting on the first official building block (which isn’t technically a function, but I digress) ‘function’:

PHP Function and Syntax

function <function name>(<parameters>) {
   /*add code here*/
}

PHP Manual Entry

Check here for version information, or anything I may have missed:

http://www.php.net/manual/en/functions.user-defined.php

Notes and Use

This is great for building blocks of code that you repeat a lot.  I like to use it when duplicating XML/HTML code, such as links or form elements, which I will outline below.  Functions, both custom and built in, are the primary building blocks of a good program.  Everything else is just procedural.

Also, on a side note: PHP Coding Standards is a good read if you’re really geeky.

An important thing to keep in mind about making custom functions is that someone has probably already made it if it doesn’t already exist in the built in functions for PHP.  Feel free to jump online and see if someone has already made a function to do what you’re trying to do.  I like to use the site HotScripts.com, which has both free and commercial PHP scripts available.  Chances are: if I need it, they have it.  It saves me a ton of time.

Note in the examples that I precede the function with some explanation of what it does, the author, etc.  This isn’t needed, but it’s a REALLY good habit.

Other Functions Referenced in Examples

Examples

Here’s the meat.  Let’s make some stuff work.

Creating Image Links

/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  This function is for displaying image links in HTML.  It's less typing,
 *  and easier to remember what needs to be slashed out.  An image
 *  with the same name as the file name of the page you're linking to needs to
 *  be placed on the server in the same path as the internal variable
 *  '$image_path' and the same extension as '$image_ext'.
 *
 *  Arguments
 *  ------------------------------------
 *  $url - URL of the link
 *  $extra_tag_html - this is any extra HTML, like class, id, or style
 *
 */

/* Build the function. */

	function create_html_link($name, $extra_tag_html) {
		/* Define internal variables. */
			$image_path = "images/";
			$image_ext   = ".jpg";

		/* Output the HTML. */
			echo
				"<a href="".$name.".php" ".$extra_tag_html.">
					<img src="".$image_path.$name.$image_ext."" />
				</a>";
	}

/* Execute the function. */

	create_html_link("home", "class="normal_link"");
	create_html_link("about", "class="normal_link"");
	create_html_link("contact", "class="normal_link"");

Calculate the Number of Days Since Some other Date

/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  Simple.  This calculates the number of days since X date.
 *
 *  Arguments
 *  ------------------------------------
 *  $date - the date in this format: 'YYYY-MM-DD HH:MM:SS'
 *
 */

/* Build the function. */

	function num_days_since($date) {
		/* Do some time math. */
			$date = strtotime($date);
			$now = time();
			$difference = $now - $date;
			$days = $difference / 86400;

		/* Output the Value. */
			return $days;
	}

/* Execute the function. */

	/* Should return 0 */
		echo num_days_since(date("Y-m-d H:i:s"));
	/* Someone's birthday at 6:02:55AM on Oct 23, 1974 */
		echo num_days_since("1974-10-23 06:02:55");
	/* Since Jan 1, 2009 - no need for time */
		echo num_days_since("2009-01-01");

Examples Elsewhere on this Site:

Holiday Notices

Conclusion

So that’s the basics.  Functions can be very powerful in reducing the code on your websites.  If you’d like to see some more custom functions, check out my Tidbit Tuesdays on PHP If you have questions, let me know in the comments.