PHP - Simpletest - 比较数字字符串

发布于 2024-08-13 06:31:24 字数 430 浏览 2 评论 0原文

我正在尝试使用 simpletest 来比较两个数字字符串,一个来自数组,一个来自对象属性。

我已经打印出这些值并且它们是相等的,但是测试总是返回 false。 有人可以帮忙吗?

这是代码:

$this->assertEqual(strval($this->createdforums[$randomforum]),
(strval($forum->getTitle)));

   print_r($this->createdforums[$randomforum]);
   print_r('<br />');
   print_r($forum->getTitle());

打印出来的值是:

1250833961 1250833961

任何建议表示赞赏。 谢谢。

I'm trying to use simpletest to compare two numeric strings, one from an array and one from an object property.

I've printed out the values and they are equal, however, the test always returns false.
Can anyone help?

Here's the code:

$this->assertEqual(strval($this->createdforums[$randomforum]),
(strval($forum->getTitle)));

   print_r($this->createdforums[$randomforum]);
   print_r('<br />');
   print_r($forum->getTitle());

The values that get printed out are:

1250833961
1250833961

Any advice appreciated.
Thanks.

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

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

发布评论

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

评论(2

醉生梦死 2024-08-20 06:31:24

您错过了断言中 getTitle 的括号。应该是...

$this->assertEqual(strval($this->createdforums[$randomforum]),
(strval($forum->getTitle())));

You missed the brackets off getTitle in the assert. should be...

$this->assertEqual(strval($this->createdforums[$randomforum]),
(strval($forum->getTitle())));
小忆控 2024-08-20 06:31:24

也许您的值周围有一些空格。在比较之前尝试修剪()它们。

Maybe you have some spaces around the values. Try to trim() them before comparing.

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