dongtou9934 2016-03-27 23:45
浏览 205

PHP 5.4 $ _GET注意:未定义的索引:

this Code works in PHP 5.3, but not in PHP 5.4 > Error Notice: Undefined index:

//station
$station = $_GET['station'];

if (!$station)
    $station = 'main';



//base path
  • 写回答

2条回答 默认 最新

  • duanjupiao4730 2016-03-28 00:15
    关注

    it depends on the setting of your error_reporting, but you should always check if the 'station' was already set through the http(s) like www.example.com?station=piccadily

    if (isset($_GET['station']) && $station = $_GET['station'])
    else $station = 'main;
    

    or simplify it to:

    $station = isset($_GET['station']) ? $_GET['station'] : 'main';
    

    since PHP7 you may write with coalesce operator:

    $station = $_GET['station'] ?? 'main';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog