>我在PHP中得到了以下代码:
class NewsletterDB {
private $connection;
public $last_query;
private $magic_quotes_active;
private $real_escape_string_exists;
function __construct() {
$this->open_connection();
$this->magic_quotes_active = get_magic_quotes_gpc();
$this->real_escape_string_exists = function_exists("mysql_real_escape_string");
$this->$connection = "";
}
public function open_connection() {
if (!isset($this->$connection)) die("error");
$this->$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
...
但是我收到以下错误:
注意:未定义的变量:/用户/中的连接...
为什么?我已经在课后的顶部定义了变量 时事通讯数据库 {...
这$this->connection
不是$this->$connection
.后者意味着:将局部变量中包含的字符串$connection
并使用该名称调用成员变量。