2016-03-27 17 views
0

このコードはPHP 5.4にPHP 5.3で動作しますが、ありません>エラー通知:未定義のインデックス:

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

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



//base path 

答えて

1

それはあなたのerror_reportingの設定に依存しますが、あなたがすべき常に '駅' がすでに www.example.com?station=piccadily

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

などのHTTP(S)を介して設定されたかどうかを確認またはそれを簡素化:

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

あなたが合体演算子で書くことがあります。

$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)に設定されている場合、そのコードを理解できません.b/cでは2行目に同じ通知が表示されますコードを実行します。 $アクションとは何ですか? –

+0

Tom K.もし私があなたにスクリプトを送ることができれば。 – Ambassador

関連する問題