add Global PHP code field to Views on condition
I think you have not followed a correct way, these are the steps to create a custom field on the basis of value of an existing text field are :


Add a field in any content type on basis of whose value you want to
display a custom field.
Add contents of that content type filling value of newly created
field say its a checkbox having 0 or 1 as its value.
Create a view of that content type.
Add fields and a custom field having some value, say ;

&lt;?php 
echo 'Astha Chauhan';
?&gt;


in output code field. 


Then add a filter of type Global:PHP and add a filter code
accordingly:

  &lt;?php    
      if ( $row-&gt;field_test_field == '2') {
       return $row-&gt;php; 
      }
      else { 
       return 'null'; 
      }  
   ?&gt;