未定义或定义的索引?决定

发布于 2024-10-20 23:55:11 字数 1237 浏览 5 评论 0原文

我有奇怪的问题。

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);

这是结果:

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"
  ............
}

在错误日志中:

[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

如果您有任何想法可能出现问题或如何修复,请告诉我。 谢谢:)

我尝试了另一个测试:

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

结果是:

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

Somethink确实很有趣:这个“lol”错误显示在输出中,但“url”错误不是!它只在日志中...为什么???这是同一个文件,位于“url”var_dump() 下的行...疯狂

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一场春暖 2024-10-27 23:55:11

如果您首先将 $this->_currentRoute 分配给变量会发生什么?

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

已解决(请参阅评论)

不幸的是,这是 Zend Server 或前沿 PHP 5.3.3 的问题。

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.

一抹淡然 2024-10-27 23:55:11

也许这不是你的错误?
尝试 ini_set('display_errors', 1);

另请参阅方法 Default_Model_Routes::getInstance()->getCurrentRoute()::__get()

阅读此内容

Maybe this is not you errors?
Try to ini_set('display_errors', 1);

And also see method Default_Model_Routes::getInstance()->getCurrentRoute()::__get()

Read this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文