2015-09-29 34 views
-2

早上好, 我想在PHP類中使用超全局的「$ _GET」,但是我的4個解決方案都沒有工作......這是我最後一次嘗試,有人可以請告訴我什麼是錯的? 謝謝

public $a; 


    function __construct($options = null, $initialize = true, $error_messages = null) { 
     $this->response = array(); 

       if(isset($_GET['album']){ 
      $this->a = $_GET['album']; 
     }else{ 
      $this->a = null 
     } 

     $this->options = array(
      'script_url' => $this->get_full_url().'/'.basename($this->get_server_var('SCRIPT_NAME')), 
      'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',$a,'/', 
      'upload_url' => $this->get_full_url().'/files/',$a,'/', 

...... 
} 
+0

您的URL是否包含'?album = '? – Epodax

+0

當然,這樣做,我試過幾個值.. –

+0

你可以考慮傳遞$ _GET給構造函數(如更好的設計方法) – BobbyTables

回答

0
if(isset($_GET['album'])) //missing paranthesis here............. 
{ 
     $this->a = $_GET['album']; 
}else{ 
     $this->a = null 
    } 
+0

哦..用於修復:)謝謝了,不過,它不工作.. –

0

它看起來像你串聯用逗號分隔的網址:

'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/files/',$a,'/', 
'upload_url' => $this->get_full_url().'/files/',$a,'/', 

但是如果$ a是空你得到雙斜槓。並且此行缺少分號

$this->a = null