Rendering field with the help of functions
The correct syntax for your approach would be:

function mymodulename_getText($entityId,$field){
    return $entityId-&gt;$field['und'][0]['safe_value'];
}


I suggest to sanitize that with a isset().