2014-10-04 163 views
-4

我有一個問題,這個字符串解析錯誤:語法錯誤意外T_CONSTANT_ENCAPSED_STRING

'Require.www' => false 

此代碼給我的錯誤:

>Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\KERNEL-DOCMS\Server.Config.php on line 5 

我該如何解決這個問題?它位於在線遊戲的serverconfig中。

完整的代碼是:

## URL 
$Config['URL'] = 
    'Default' 
     'Require.www' => false, // www.example.com 
     'SSL.enabled' => true, // https:// 
     'Server' => '***', // public server 
     'Lang' => 'en_US' // GLOBAL. 
    , 
    'Other' => 
     //'example.com' => ['Require.www' => false, 'SSL.enabled' => false, 'Lang' => 'es_ES', 'MySQL' => ['host' => '127.0.0.1','user' => 'root','pass' => '','dbname' => 'cmsdb']] 
    , 
    'devPrivateServer' => 'localhost' // private developer server 
; 

## SQL Server Data 
$Config['MySQL'] = 
    'host' => '127.0.0.1', 
    'user' => '***', 
    'pass' => '***', 
    'dbname' => 'do' 
; 
// Do not tuch the code below this text if yuo do not know what yuo're doing 
      define("DB_DSN", "mysql:host".$Config['MySQL'] ['host'].";dbname".$Config['MySQL']['dbname']."");//this constant will 
define ("DB_USERNAME", $Config['MySQL']["user"]); //username of database 
define ("DB_PASSWORD", $Config['MySQL']["pass"]); //username of database 
define ("CLS_PATH", "class"); //the class path of our project 
+3

你沒有顯示相關的代碼。提供完整的聲明。 – mithunsatheesh 2014-10-04 12:50:50

+0

以擴展最後一條評論,像這樣的錯誤可以顯示實際錯誤後的行號,因爲上一行末尾的缺失符號可能導致下一行成爲無效語法。 – JimL 2014-10-04 12:52:36

回答

1

這主要是語法錯誤。如果要聲明一個數組,你要麼使用array()或簡寫[]

$Config['URL'] = array(
    'Default' => array(
     'Require.www' => false, // www.example.com 
     'SSL.enabled' => true, // https:// 
     'Server' => '***', // public server 
     'Lang' => 'en_US' // GLOBAL. 
    ) 
    , 
    'Other' => '' 
     //'example.com' => ['Require.www' => false, 'SSL.enabled' => false, 'Lang' => 'es_ES', 'MySQL' => ['host' => '127.0.0.1','user' => 'root','pass' => '','dbname' => 'cmsdb']] 
    , 
    'devPrivateServer' => 'localhost' // private developer server 
); 

$Config['MySQL'] = array(
    'host' => '127.0.0.1', 
    'user' => '***', 
    'pass' => '***', 
    'dbname' => 'do' 
); 
+0

謝謝,錯誤已修復,但現在又出現了另一個錯誤:解析錯誤:語法錯誤,第5行中的C:\ xampp \ KERNEL-DOCMS \ Server.Config.php中的意外T_DOUBLE_ARROW如何解決這一問題? – Joyfabio 2014-10-04 13:09:20

+0

@Joyfabio 5號線?發佈您正在使用的當前代碼。只需使用這個答案並將其應用於你的,這應該沒有問題 – Ghost 2014-10-04 13:11:18

+0

錯誤總是關於'Require.www'=> false,// www.example.com與此代碼 – Joyfabio 2014-10-04 13:13:27

相關問題