尝试使用phpactiverecord库时出现php语法错误

时间:2012-11-04 20:15:55

标签: php phpactiverecord

我有代码

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] [错误] [客户端127.0.0.1] PHP解析错误:语法错误,第27行Server.php中的意外T_VARIABLE

on $server = new Server;

如何逃脱它?

1 个答案:

答案 0 :(得分:4)

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

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

$server = new Server;

即。把);放在前一行。