解析错误:语法错误,第19行/PHOP.php中的意外'['

时间:2015-01-13 03:58:39

标签: php

class Config
{
   const Caching = true;
   const Logging = false;
   const LogFile = 'log.txt';

   const PublicUrl = 'http://vptelevision.com/op';

   static $RemotePaths = [
      "http://awcommunity.org/romperroom",
      "http://aw.platform3d.com/multipath"
   ];

   static $AssetDirectories = [
      "models",
      "textures",
      "avatars",
      "sounds",
      "seqs",
   ];

   static $Plugins = [
      "prim",
   ];
}

我正在使用Netbeans并且根本没有捕获它。我很难搞清楚这段代码有什么问题

5 个答案:

答案 0 :(得分:3)

您的PHP版本不支持short array syntax。考虑升级到PHP 5.4+,或使用array()而不是[]

答案 1 :(得分:1)

如果您正在使用PHP 5.4+开发数组,则可能需要执行以下操作:

static $RemotePaths = array(
      "http://awcommunity.org/romperroom",
      "http://aw.platform3d.com/multipath"
);

基本上,在PHP中,数组使用任意数量的逗号分隔作为参数。

array(
    key  => value,
    key2 => value2,
    key3 => value3,
    ...
)

如果没有数组值的键声明,则将它们分配给从0开始递增1的值。

这里的数组与:

相同
static $RemotePaths = array(
  [0] => "http://awcommunity.org/romperroom",
  [1] => "http://aw.platform3d.com/multipath"
);

答案 2 :(得分:0)

仅在php 5.4中引入的短样式数组。您正在使用比此更早的代码运行代码。切换回长样式数组初始值设定项:

class Config
{
   const Caching = true;
   const Logging = false;
   const LogFile = 'log.txt';

   const PublicUrl = 'http://vptelevision.com/op';

   static $RemotePaths = array(
      "http://awcommunity.org/romperroom",
      "http://aw.platform3d.com/multipath"
   );

   static $AssetDirectories = array(
      "models",
      "textures",
      "avatars",
      "sounds",
      "seqs",
   );

   static $Plugins = array(
      "prim",
   );
}

答案 3 :(得分:0)

您的版本不支持短样式数组。像这样使用array()函数使用数组

 static $AssetDirectories = array(
      "models",
      "textures",
      "avatars",
      "sounds",
      "seqs"
   );

希望这有助于你

答案 4 :(得分:0)

您必须在PHP5.4或更高版本上运行您的应用程序才能使用短数组语法,升级到PHP5.4或将代码更改为

class Config
{
   const Caching = true;
   const Logging = false;
   const LogFile = 'log.txt';

   const PublicUrl = 'http://vptelevision.com/op';

   static $RemotePaths = array(
      "http://awcommunity.org/romperroom",
      "http://aw.platform3d.com/multipath"
   );

   static $AssetDirectories = array(
      "models",
      "textures",
      "avatars",
      "sounds",
      "seqs",
   );

   static $Plugins = array(
      "prim",
   );
}
相关问题