dongyong5912 2012-08-07 18:10
浏览 46
已采纳

PHP IF / Else不工作

I have what should be a very simple question. I am using the following simple PHP if/else statement. When nomobile is not defined or not equal to "true", then the javascript shown below should execute. If it is equal to true, then it should not execute. However, the javascript is executing even when nombobile=true. There is probably a minor typo that is messing everything up, but I am driving myself crazy trying to find what is wrong and can't figure it out.

<?php
  if ($_GET["nomobile"]!="true")
    {echo '
    <script type="text/javascript">
    if (screen.width <= 699) {
    document.location = "http://www.heliohost.org/m/";
    }
    </script>';}
  else {} ?>
  • 写回答

4条回答 默认 最新

  • dongpengqin3898 2012-08-07 18:16
    关注

    Could it be that you're not checking if the $_GET value is set? Taking this statement of yours and converting it into code should produce this:

    When nomobile is not defined or not equal to "true"

    if (!isset($_GET["nomobile"]) || $_GET["nomobile"] != "true"){ ... }
    

    There might be issues happening if it's not set.

    I hope that helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM