2016-03-27 85 views
0

这个代码在PHP 5.3,但不是在PHP 5.4>错误注意:未定义指数:

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

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



//base path 

回答

1

这取决于你的error_reporting的设置,但你应该总是检查 '站' 通过HTTP(S)等 www.example.com?station=piccadily

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

已经被设置或将其简化为:

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

因为PHP7您可以用COALESCE操作写:

$station = $_GET['station'] ?? 'main'; 
0
<?php 
    $station = $_GET['station']; 
    error_reporting(0); 
    if (isset ($station)) : 
     $station = 'main'; 
    else : 
     $action = 'null'; 
    endif; 
?> 
+0

同一玩家脚本 1个服务器Centos的6.7 PHP 5.3 http://195.154.68.186/工作 2.服务器Centos的7 PHP 5.4的HTTP: //37.59.14.143/player/index.php不加载swf文件 – Ambassador

+0

我不明白代码,如果error_reporting被设置为ALL(0)之前,你会在第二行得到相同的通知执行代码。什么是$动作? –

+0

汤姆K.如果你想我可以给你发送剧本。以测试 – Ambassador