views with multiple contextual filters - should return data only when both or any one filter is present Views of content is having two contextual filter. For some reason node object is available to views so it is passing through url's 7th argument.

1.Content: Has taxonomy term ID
Configuration: Php Code

$nid = arg(7);
$node = node_load($nid);
if($node &amp;&amp; isset($node-&gt;field_tags)) {
      $related = field_get_items('node', $node, 'field_tags');//dpm($related);
      foreach($related as $tag) {
          $view_par[] = $tag['tid'];
          //dpm($tag);
      }
return implode(',', $view_par);
}
else{
return 0;
}


2.Content: Nid (Ref: entity-reference-and-nested-arguments-in-views)

$nid = arg(7);
$node = node_load($nid);
$Related_ids = array ();
    $Related = field_get_items ('node', $node, 'field_some_er')    // Get the entity reference scope
    if ($related &amp;&amp; is_array ($related) &amp;&amp; sizeof ($related)&gt; 0) {
      for ($i = 0; $i &lt;count ($related); $i++) {
        $ Related_ids [] = $related[$ i]['target_id'];
      }
    }
    return implode ('+', $related_ids) // It returns the values ​​of the field entity reference


Relationships:

Content: Taxonomy terms on node (Require this relationship :TRUE)
Content entity referenced from field_er_in_content (Require this relationship :TRUE)


With above configuration/modifying how to retrieve views's data only when

1. Any one of the filter should be present i.e either field_tags(term reference field) or field_some_er (entityreference field)
2. Both filter could be present.


but should not retrieve when both value is absent. Is there something can be done using common variable like found flag that can be shared to both php code and break the view operation.
Perhaps this is what you're looking for:
https://www.drupal.org/node/1871388

Otherwise, it looks like you might want to set up what your contextual filters do when the arguments  are not available:

https://www.drupal.org/node/1578574