简体   繁体   中英

PHP error suppression on static class function call

I've got this call to Pear Mailer that gives me warnings not to be called statically but it works and I'm fully aware of that warning. Can I suppress it with an @ as I need other warnings?

$mail_smtp_public =& Mail::factory("smtp", $smtp_params_public);

These, obviously, do not work:

$mail_smtp_public =& @Mail::factory("smtp", $smtp_params_public); $mail_smtp_public =& Mail::@factory("smtp", $smtp_params_public);

Maybe try this:

@$mail_smtp_public =& Mail::factory("smtp", $smtp_params_public);

or

try {
    $mail_smtp_public =& Mail::factory("smtp", $smtp_params_public);
    if ($mail_smtp_public) {
        throw new Exception('Your other message');
    }
} catch(Exception $e) {
    echo $e->getMessage();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM