【发布时间】:2010-12-30 06:37:39
【问题描述】:
T_PAAMAYIM_NEKUDOTAYIM 听起来很异国情调,但对我来说绝对是一派胡言。我将其全部追溯到这行代码:
<?php
Class Context {
protected $config;
public function getConfig($key) { // Here's the problem somewhere...
$cnf = $this->config;
return $cnf::getConfig($key);
}
function __construct() {
$this->config = new Config();
}
}
?>
在构造函数中,我创建了一个 Config 对象。这是课程:
final class Config {
private static $instance = NULL;
private static $config;
public static function getConfig($key) {
return self::$config[$key];
}
public static function getInstance() {
if (!self::$instance) {
self::$instance = new Config();
}
return self::$instance;
}
private function __construct() {
// include configuration file
include __ROOT_INCLUDE_PATH . '/sys/config/config.php'; // defines a $config array
$this->config = $config;
}
}
不知道为什么这不起作用/错误意味着什么......
【问题讨论】:
标签: php