itommy
V2EX  ›  问与答

入门级php问题

  •  
  •   itommy · Jan 21, 2012 · 4239 views
    This topic created in 5421 days ago, the information mentioned may be changed or developed.
    代码是在mac上写的和测试的, mamp, localhost测试,网站显示没有问题;

    但,在ec2上的lamp 和 xampp 跑同样的代码都出现了以下内容:

    "notice: undefined index: status in c:\xxx\xx.php on line 4"

    下面是php file里的line 4:

    " if($_GET['status'] == 'logout'){ "

    可以理解为什么会显示那个"undefined index"的notice, 但为什么在mamp上测试的时候就不显示呢?

    先谢谢各位大牛. :)
    4 replies  •  1970-01-01 08:00:00 +08:00
    yesmeck
    yesmeck
    Jan 21, 2012
    1
    可以检查一下php.ini里的error_reporting和display_errors这两个配置
    jkeylu
    jkeylu
    Jan 21, 2012 via Android
    2
    $_GET 数组中没有 status 这个索引,原因是访问当前地址时没有 &status=something ,可以使用前判断是否设置
    if (isset($_GET['status']))
    itommy
    itommy
    OP
    Jan 21, 2012
    3
    @yesmeck 明白了!看到了里面 error_reporting的 配置。 谢谢!
    itommy
    itommy
    OP
    Jan 21, 2012
    4
    @jkeylu 恩恩, 明白这个产生这个 notice 的缘故,只是不知道为什么在mamp上没有,在lamp 和xampp上都有。 是因为php.ini里面的配置difference, 如yesmeck所说。

    thanks, anyway. :)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4993 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 03:20 · PVG 11:20 · LAX 19:20 · JFK 22:20
    ♥ Do have faith in what you're doing.