\在PHP中做什么?
例如,CSRF4PHP有\FALSE,\session_id和\Exception:
public function __construct($timeout=300, $acceptGet=\FALSE){
$this->timeout = $timeout;
if (\session_id()) {
$this->acceptGet = (bool) $acceptGet;
} else {
throw new \Exception('Could not find session id', 1);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试处理我的api中的一些错误。但是,我尝试了许多方法来执行所需的操作?
在代码中,我使用了Exception \ Exception,这是另一个扩展到Exception的类“ use \ Exception”。这些选项均无效。我需要执行块捕获吗?
//Piece of source in the begin of file
namespace Business\Notifiers\Webhook;
use \Exception;
class MyException extends \Exception {}
//Piece of source from my class
try{
$products = $payment->getProducts();
if(count($products) == 0)
return;
$flight_id = $products[0]->flight_id;
$this->message = 'Sir, we have a new request: ';
$products = null; //Chagind it to null to force an error..
foreach($products as $product){
$this->appendAttachment(array(
'color' => '#432789',
'text' =>
"*Name:* $product->name $product->last_name \n" .
"*Total Paid:* R\$$product->price\n",
'mrkdwn_in' => …Run Code Online (Sandbox Code Playgroud)