if equals 上的奇怪 php 输出

发布于 2025-01-08 15:06:40 字数 658 浏览 3 评论 0原文

我已在服务器上上传了一个版本,但出现了本地环境中没有的错误。 我有这个对象

stdClass Object (
    [type] => education 
    [tutor_title] => Computer skills for the workplace 
    [tutor_title_description] => portland college 
)

,当我执行此块时:

if ('education' == $qualification->type)
{
    echo 'yes';die();
}
else 
{
    echo 'no';die();
}

我总是得到“否”。我不知道为什么。我尝试这样做:

  • if ('education' === $qualification->type)
  • if ($qualification->type == 'education')
  • < code>if ($qualification->type === 'education')

和相同的输出。这很奇怪,为什么会出现这种情况呢?

I have uploaded a version on a server and I get an error which I did not have on local environment.
I have this object

stdClass Object (
    [type] => education 
    [tutor_title] => Computer skills for the workplace 
    [tutor_title_description] => portland college 
)

and when I do this block:

if ('education' == $qualification->type)
{
    echo 'yes';die();
}
else 
{
    echo 'no';die();
}

I always get no. I don't know why. I have tried to do:

  • if ('education' === $qualification->type)
  • if ($qualification->type == 'education')
  • if ($qualification->type === 'education')

and same output. This is strange why is this happening?

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

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

发布评论

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

评论(2

沙与沫 2025-01-15 15:06:40

如果执行var_dump($qualification);,您会得到什么? “教育”之后是否还有一个空格?

What do you get if you do var_dump($qualification);? Is there perhaps a space after "education" or so?

ˉ厌 2025-01-15 15:06:40

尝试使用

if ('education' == trim($qualification->type))

In以防类型周围有任何空格字符。

Try using

if ('education' == trim($qualification->type))

In case there are any space characters around type.

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