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' => 3,
'path' => drupal_get_path('module', 'MYMODULE') . '/views',
);
}
In MYMODULE/views/mymodule.views.inc:
function mymodule_views_data() {
$data['node']['custom_stuff'] = array(
'field' => array(
'title' => t('Custom link'),
'help' => t('Provide a custom content link.'),
'handler' => '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->additional_fields['type'] = 'type';
}
function query() {
$this->ensure_my_table();
$this->add_additional_fields();
}
function render($values) {
$type = $this->get_value($values, 'type');
$nid = $this->get_value($values, 'nid');
return mymodule_print_my_link($nid, $type);
}
};