Exception::getCode

(PHP 5, PHP 7)

Exception::getCode锟斤拷取锟届常锟斤拷锟斤拷

说锟斤拷

final public Exception::getCode ( void ) : int

锟斤拷锟斤拷锟届常锟斤拷锟诫。

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

Exception 锟斤拷锟斤拷锟斤拷锟酵o拷integer锟斤拷锟斤拷锟届常锟斤拷锟诫,锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫匡拷锟杰凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷(锟斤拷锟斤拷锟斤拷 PDOException 锟叫凤拷锟斤拷 string)锟斤拷

锟斤拷锟斤拷

Example #1 Exception::getCode()示锟斤拷

<?php
try {
    throw new 
Exception("Some error message"30);
} catch(
Exception $e) {
    echo 
"The exception code is: " $e->getCode();
}
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

The exception code is: 30

锟轿硷拷

  • Throwable::getCode()