2016-03-27 20 views
0

bu Kod PHP 5.3 çalışır, ancak PHP 5.4> Hata Bildirimi içinde: Undefined index:

sizin error_reporting ayarına bağlıdır
//station 
$station = $_GET['station']; 

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



//base path 

cevap

1

ancak gerektiği her zaman 'istasyon' zaten www.example.com?station=piccadily

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

gibi http (s) aracılığıyla kurulmuştur olmadığını kontrol veya bir basitleştirmeye:

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

PHP7 beri kaynaşabilecek operatörüyle yazabilirsiniz:

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

aynı Player Kod 1 Sunucu Centos 6.7 PHP 5.3 http://195.154.68.186/ 2. Sunucu Centos 7 PHP 5.4 http çalışır: //37.59.14.143/player/index.php swf dosyasını yüklemiyor – Ambassador

+0

Bu kodu anlamıyorum, b/c ikinci satırda aynı bildirimi alacaksınız, eğer error_reporting ALL (0) olarak ayarlanmışsa kodu yürütmek. $ Eylem nedir? –

+0

Tom K. isterseniz size senaryoyu gönderebilirim. – Ambassador

İlgili konular