【问题标题】:Php retrieve query and use in If statmentphp检索查询并在If语句中使用
【发布时间】:2015-03-16 22:58:46
【问题描述】:

好的,我正在尝试做一些我通常可以在 ASP 中轻松完成的事情,但出于某种原因,尽管阅读了文档,但我可以弄清楚为什么这个 If 语句会显示我的代码。

我试图简单地检索 ?fs=success 的查询字符串

如果为真则显示html,如果不是则什么也不做。即使不存在查询字符串,页面也会显示代码,我哪里出错了。谢谢

if ($_GET['fs'] = 'success') {
    echo "<div class='container'><div class='row configureCellSplitBG-ouline color-contrast-yellow text-center'><h3>THANK YOU</h3><p>We have recieved your message and will get back to you soon!</p></div></div>";
}

【问题讨论】:

  • if ($_GET['fs'] = 'success') { 更改为if ($_GET['fs'] == 'success') {。注意双精度等于==;
  • 总是很难用代码片段来分辨,但如果它在屏幕上显示你的 php 代码,你必须质疑你的代码是否真的通过 php 处理器运行。
  • 谢谢大家。只是对php不是很熟悉。说真的,为什么我被否决了?

标签: php if-statement query-string


【解决方案1】:

Single = 设置它,double 等于检查值。

http://php.net/manual/en/language.operators.comparison.php

if ($_GET['fs'] == 'success') {

【讨论】:

    猜你喜欢
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 2012-02-03
    • 1970-01-01
    • 2017-04-21
    • 2013-01-08
    • 2012-01-16
    相关资源
    最近更新 更多