Code to thwart duplicate content

Here is a reference that helped me thwart duplicate content in php.

if((is_home() && ($paged < 2 )) || is_single() || is_page() || is_category()){
echo ‘<meta name=”robots” content=”index,follow” />’;
} else {
echo ‘<meta name=”robots” content=”noindex,follow” />’;}