有时 PayPal 会中断,并且不会返回 tracking_id。同时在自己的服务器上完成支付。这对我来说是个问题,因为即使付款成功,我的服务器最终在数据库表中有一个空白的 tracking_id 列,这给我带来了很多问题
如果再次发生这种情况,下面的 if 语句是否足以捕获此类事件?
if( !isset($trackingId) || empty($trackingId) || $trackingId == null || $trackingId == "" ) {
// something is wrong
} else {
// continue as normal
}
最佳答案
使用empty .
Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.
The following things are considered to be empty:
"" (an empty string) 0 (0 as an integer) 0.0 (0 as a float) "0" (0 as a string) NULL FALSE array() (an empty array) $var; (a variable declared, but without a value)
关于php - PayPal 的跟踪 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18873598/