Display if and when a particular field exists [I have been on D6 for ages, and just shifting to D7.]

In D6, I was using the following in the node.tpl.php:

&lt;?php if (content_format('field_occupation', $field_occupation[0]) != '') : ?&gt;
&lt;?php foreach ($field_occupation as $occupation) { ?&gt;
&lt;strong&gt;Primary occupation: &lt;/strong&gt;&lt;?php print content_format('field_occupation', $occupation) ?&gt;&lt;?php } ?&gt;
&lt;?php endif; ?&gt;

But this doesn't seem to work in D7.

How can I make it work?
Welcome to d7 - just in time as d6 will soon become unsupported.
In D7, content_format is deprecated.

https://www.drupal.org/node/1054586 

Check out this for how to render entity fields in d7: https://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way

You'll have to adapt your existing script to this new rendering method. It might be a good opportunity to clean up the presentation and readability of the script so that you'll be prepared for the inevitable migration to d8!