当 TestPage.php 在浏览器中运行时,'trying to create new obj...' 被回显,但没有别的。构造函数没有被调用吗?
这不是任何一个类的完整代码,但希望有人告诉我哪里出错了......
测试页面.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/plain; charset=UTF-8">
<title></title>
</head>
<body>
<?php
class MyClass {
$api_key = 'somestring';
$username = 'username';
echo 'trying to create new obj...';
$myObj = new MyClass($api_key, $username);
echo 'new obj created...';
...
?>
</body>
</html>
MyClass.class.php
<?php
class MyClass {
protected $_api_key;
protected $_username;
public function __construct($api_key, $username) {
echo 'entered constructor...';
$this->_api_key = $api_key;
$this->_username = $username;
echo 'leaving constructor...';
}
...
}
?>