略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Error handling

2024-09-17

Error handling

All SAMConnection methods that provide access to messaging operations return FALSE if an error occurred in processing the request. In addition the SAMConnection object has two properties, "errno" and "error", that provide respectively the error number and text description of the last error to occur on the connection.

Example #1 Handling an error from a method that returns no result

<?php
if (!$conn->commit()) {
    
// The commit failed!
    
echo "Commit failed ($conn->errno$conn->error";
}
?>

Example #2 Handling an error from a method that returns a result

<?php
$correlid 
$conn->send('queue://send/test'$msg);

if (!
$correlid) {
  
// The Send failed!
  
echo "Send failed ($conn->errno$conn->error";
} else {
  
/* ... */
}
?>
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/sam.errors.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3