我想知道我到底有多少成功和失败。我想用阵列功能,但我不知道如何从这里继续:php - 数组元素
public function array_internal($the_string)
$pass= Array();
$failed = Array();
if(strstr($the_string,"Success"))
{
$pass[] = +1;
}
else
{
$failed[] = +1;
}
count($pass);
这一步是运行的每个assert函数是这样的:
try {
$this->assertEquals("off", $this->getValue("page"));
throw new PHPUnit_Framework_AssertionFailedError("Success");
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$this->array_internal($e->toString());
}
函数本身是好的。我的问题只与柜台。
谢谢!
编辑 我试图做这样的事情:
$pass= 0;
$failed = 0;
public function array_internal($the_string)
if(strstr($the_string,"Success"))
{
$pass += 1;
}
else
{
$failed += 1;
}
$pass;
我认为'array_internal'被多次调用,因为在功能上没有循环。全局变量会更好。 - 我看到你已经更新了你的答案;) – Harmen 2010-11-10 16:17:40
@哈曼是的我把初始化了,但原来的问题也是每次重置它。我同意他们应该是全球性的或以其他方式处理。 – Fosco 2010-11-10 16:20:13
你能向我解释一下如何做全球变量吗? (并且是的,'array_internal'被多次调用) – Ronny 2010-11-10 16:27:56