class test extends PDO
{
function __construct()
{
try {
try {
parent::__construct('sadf');
} catch (PDOException $e) {
echo $e->getMessage();
} throw new PDOException('234234'); } catch (PDOException $e) {
$this->err($e);
# self::err($e);
} } public function err($e)
{
var_dump($e);
}
}$t = new test();
为嘛我在构造函数中调用父类的构造函数,故意出错后。子类构造函数的异常捕获中$this变量为空。但是却可以用self::err 这个静态调用方式?
{
function __construct()
{
try {
try {
parent::__construct('sadf');
} catch (PDOException $e) {
echo $e->getMessage();
} throw new PDOException('234234'); } catch (PDOException $e) {
$this->err($e);
# self::err($e);
} } public function err($e)
{
var_dump($e);
}
}$t = new test();
为嘛我在构造函数中调用父类的构造函数,故意出错后。子类构造函数的异常捕获中$this变量为空。但是却可以用self::err 这个静态调用方式?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货