我的网站在XAMPP中使用PHP 5.6正常运行。
foreach ($treeNodeIterator as $nodeKey => $node) {
$currentLevel = $nodeKey->getNodeLevel();
if ($currentLevel > $depth) {
$depth = $currentLevel;
}
}
然后我发现我的服务器运行的是PHP 5.4。所以现在我明白了 服务器日志文件上的以下错误消息:
[13-Sep-2015 12:33:19 America/Denver] PHP Fatal error: Call to a member function getNodeLevel() on a non-object in treeNode.php line 82
这是TreeNodeIteratorKey类:
class TreeNode {
protected $name;
protected $value;
protected $children;
protected $customData;
//...
}
class TreeNodeIterator implements Iterator {
private $traversalMode;
private $rootNode;
private $nodesToVisit;
private $nodesToVisitLevels;
private $currentNodeIteratorKey;
const TRAVERSAL_MODE_BFS = 0;
const TRAVERSAL_MODE_DFS = 1;
const NUM_TRAVERSAL_MODES = 2;
public function current() {
return $this->nodesToVisit[0];
}
public function key() {
return $this->currentNodeIteratorKey;
}
}
class TreeNodeIteratorKey {
private $nodeIndex;
private $nodeLevel;
private $customData;
//...
}