PHP code contextual filter (arguments) I try to display a list of content with exposed filter in Drupal 7 and Views 3, I create a page and it works, but I also want to display a map with the filter, so I create a block for the gmap and for get the information about the filter I add a contextual filter with php code like this (where province is the name of the field)

return $_GET["province"];


In Drupal 6 it works this method, but in Drupal 7 I receive this error


  Notice: Undefined index: province in eval() (line 1 of /pathtomodule/views/plugins/views_plugin_argument_default_php.inc(49) : eval()'d code).


So where is the error, I return only one argument (I know that I need some control if the code is null, but in this case I )
Notice: Undefined index: province in eval() (line 1 of /pathtomodule/views/plugins/views_plugin_argument_default_php.inc(49) : eval()'d code).


This error occurs when the array key province does not exist. The PHP documentation goes into greater detail - http://www.php.net/manual/en/language.variables.basics.php


  Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name... E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.


Instead of

return $_GET["province"];

Use isset() logic. Also, you shouldn't be directly accessing $_GET, $_POST or $_REQUEST; best practice is to use drupal_get_query_parameters()

$param = drupal_get_query_parameters();
if (isset($param['province'])) {
  return $param['province'];
}
return NULL;


To address the problem in your comment:


  But i receive: Notice: Undefined offset: 1 in location_handler_argument_location_proximity-&gt;query()


This is (for all intrinsic purposes) the same as the undefined index; location_handler_argument_location_proximity-&gt;query() is expecting an array with at least two elements (offset 0 and 1), and that method expected, but did not receive an array with two elements. It might not even be getting an array.