<?php
//model
class User extends CActiveRecord
{
public function getFullname()
{
if ($this->first_name && $this->last_name) {
return $this->first_name . ' ' . $this->last_name;
}
return 'Unknown';
}
}
?>

//view
<span><?php echo $user->fullname ?></span>
<?=$user->getFullname()?>