Move php in views to module
You definitely want to create a views handler with your custom php code. This is the standard way to do custom php stuff on views module.

Here you have an example:

mymodule.info

...
files[] = views/handlers/views_handler_field_node_link_custom_stuff.inc
...


mymodule.module

/**
 * Implements hook_views_api().
 */
function mymodule_views_api() {
  return array(
    'api' =&gt; 3,
    'path' =&gt; drupal_get_path('module', 'MYMODULE') . '/views',
  );
}


In MYMODULE/views/mymodule.views.inc:

function mymodule_views_data() {
  $data['node']['custom_stuff'] = array(
    'field' =&gt; array(
      'title' =&gt; t('Custom link'),
      'help' =&gt; t('Provide a custom content link.'),
      'handler' =&gt; 'views_handler_field_node_custom_stuff',
    ),
  );
  return $data;
}


MYMODULE/views/handlers/'views_handler_field_node_link_custom_stuff.inc

/**
 * Field handler to present some custom HTML.
 */
class views_handler_field_node_custom_stuff extends views_handler_field_node {
  function construct() {
    parent::construct();
    $this-&gt;additional_fields['type'] = 'type';
  }
  function query() {
  $this-&gt;ensure_my_table();
  $this-&gt;add_additional_fields();
  }
  function render($values) {
    $type = $this-&gt;get_value($values, 'type');
    $nid = $this-&gt;get_value($values, 'nid');
    return mymodule_print_my_link($nid, $type);
  }
};