-3

我有代码

ActiveRecord\Config::initialize(function($cfg) {
  $cfg->set_model_directory("models");
  $cfg->set_connections(array("development" => "mysql://root:123@localhost/server"));
}

$server = new Server;

为什么我得到错误

[Sun Nov 04 22:11:49 2012] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_VARIABLE in Server.php on line 27

$server = new Server;

如何逃脱它?

4

1 回答 1

4

您在前一行有语法错误 - 您的功能尚未完成。尝试

 ActiveRecord\Config::initialize(function($cfg) {
  $cfg->set_model_directory("models");
  $cfg->set_connections(array("development" => "mysql://root:123@localhost/server"));
});

$server = new Server;

即放在);前一行。

于 2012-11-04T20:24:38.600 回答