php 基本问题

function getRepositories() {
foreach ($this->_parentPaths as $parentPath) {
$parentRepos = $parentPath->getRepositories();}}
有段正确的代码
parentpath 明明是一个变量 怎么有了函数功能了?
$parentPath->getRepositories()到底返回了什么?

完整函数如下

function getRepositories() {
// lazily load parent paths
if ($this->_parentPathsLoaded) return $this->_repositories;

$this->_parentPathsLoaded = true;

foreach ($this->_parentPaths as $parentPath) {
$parentRepos = $parentPath->getRepositories();
foreach ($parentRepos as $repo) {
if (!$parentPath->getSkipAlreadyAdded()) {
$this->_repositories[] = $repo;
} else {
// we have to check if we already have a repo with the same svn name
$duplicate = false;
foreach ($this->_repositories as $knownRepos) {
if ($knownRepos->path == $repo->path && $knownRepos->subpath == $repo->subpath) {
$duplicate = true;
break;
}
}

if (!$duplicate && !in_array($repo->path, $this->_excluded, true)) {
$this->_repositories[] = $repo;
}
}
}
}

return $this->_repositories;
}

第1个回答  2012-01-04
只不过是一个运算符的问题
“ = ” 是赋值的意思 ,把 = 右边的值赋给左边的变量
“ -> ”我就不知道了
“ > ” 也是赋值类的

我不大懂PHP语言,但和JS C++等都类似
系统地学把,运算符都没懂就看这长条函数
W3Cschool-
第2个回答  2012-01-04
$parentPath是一个实例化的对象
返回_repositories这个方法的结果本回答被提问者采纳
第3个回答  2012-01-11
返回 $this->_repositories;的结果啊

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网