<?php
class LoginException extends Exception
{
public function __construct($message = null, $code = 0)
{
parent::__construct($message, $code);
//error_log($this->getMessage(), 3, 'D:/error/testLoginException.log');
error_log($this->getTraceAsString(), 3, 'D:/error/testLoginException.log');
}
}
try {
$link = @mysql_connect('localhost', 'dfdfdf', 'fgfgfgf');
if (!$link) {
throw new LoginException('数据库连接失败');
}
} catch (LoginException $e) {
echo $e->getMessage();
}

Paste_Image.png

Paste_Image.png