【发布时间】:2015-06-14 10:21:33
【问题描述】:
尝试计算我的邮箱中未查看的电子邮件,我的脚本会进行计数,但是当没有未查看的电子邮件时,结果始终为 1 且没有 0。知道为什么吗?
这里是我到目前为止的代码。
php:
$hostname = '{imap.example.com:993/imap/ssl}INBOX';
$username = 'myemail@example.co.uk';
$password = 'mypass';
$imap = imap_open($hostname, $username, $password) or die("imap connection error");
$result = imap_search($imap, 'UNSEEN');
$new_inbox_msg = count($result);
echo $new_inbox_msg
【问题讨论】:
-
你试过
var_dump()ing$result吗? -
您应该始终透明地标记您对问题所做的更改,如果它们不重要的话。否则事情会变得非常混乱......
-
感谢@JonStirling 添加 var_dump 结果为 int(1)
-
@SNos 不,它没有。首先,您编辑了您的问题,因此代码的上下文完全改变了,现在您在问题的 cmets 和 arkascha 的答案的 cmets 中给出了不同的答案。请自行整理并确保您告诉我们的内容准确无误且与提供的代码一致。