Search code examples
phpapachezend-frameworkzend-serverundefined-index

Undefined or defined index ? Decide


I have strange problem.

Line 61: $this->_currentRoute = Default_Model_Routes::getInstance()->getCurrentRoute();
.......... other code ..........
Line 86: var_dump(isset($this->_currentRoute['url']));
Line 87: var_dump($this->_currentRoute['url']);
Line 88: if ($this->_currentRoute['url'] == $currentUrl)
Line 89:     $navigation[$key]['active'] = true;
Line 90: var_dump($this->_currentRoute);

This is result:

bool(true)
string(62) "cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1"
array(17) {
  ["url"]=>
  string(62) "cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1"
  ["type"]=>
  string(7) "article"
  ............
}

And in the error log:

[09-Mar-2011 19:49:32] PHP Notice:  Undefined index: url in ...file... on line 87
[09-Mar-2011 19:49:32] PHP Notice:  Undefined index: url in ...file... on line 88

Please, if you have any ideas where could be problem or how to fix, tell me. Thank you :)

I have tried another test:

$test = array();
echo $test['lol'];

With this result:

Notice: Undefined index: lol in ...file... on line 92

Somethink really interesting: THIS 'lol' error is displayed in output, BUT the 'url' error IS NOT ! It is only in the log ... why ????? It's same file, line under the 'url' var_dump() ... crazy


Solution

  • What happens if you assign $this->_currentRoute to a variable first?

    $route = $this->_currentRoute;
    var_dump(array_key_exists('url', $route));
    var_dump(isset($route['url']));
    print "PRINTING: ".$route['url'];
    die("ENDING ON LINE [".__LINE__."] !!!");
    

    Solved (see comments)

    This was unfortunately an issue with Zend Server, or bleeding edge PHP 5.3.3.