我认为这个问题是不言自明的,这里是代码:
HTTP 请求:localhost/execute.php?password=testing&command=create&api=api
这是执行代码的一部分。
try
{
$TFA_SAMP->createUser($_GET['email'], $_GET['cellphone'], $_GET['area_code']);
}
catch(Exception $createError)
{
echo $createError->getMessage();
}
这是类方法:
function createUser($email, $cellphone, $areaCode = 1)
{
if(!isset($email))
throw new BadMethodCallException('(CTFA_SAMP->createUser) email ('. $email .') is missing.');
if(!isset($cellphone))
throw new BadMethodCallException('(CTFA_SAMP->createUser) cellphone ('. $cellphone .') is missing.');
$authyLibrary = new Authy_Api($this->API, $this->connectionURL);
$requestResult = $authyLibrary->registerUser($email, $cellphone, strval($areaCode));
if($requestResult->ok())
{
echo $requestResult->id();
}
else
{
foreach($requestResult->errors() as $field => $message)
echo "$field = $message";
}
}
PHP 页面打印:
注意:未定义索引:第 46 行 D:\xampp\htdocs\tfasamp\execute.php 中的电子邮件
注意:未定义索引:第 46 行 D:\xampp\htdocs\tfasamp\execute.php 中的手机
注意:未定义索引:第 46 行 D:\xampp\htdocs\tfasamp\execute.php 中的 area_code
(CTFA_SAMP->createUser) 电子邮件 () 丢失。
当我使用异常来显示它们时,如何防止 PHP 给我这些通知?