Sometimes PayPal breaks, and it doesn't return a tracking_id. At the same time, it completes the payment on it's own servers. This is a problem for me, because even thought the payment was successful, my server ends up with a blank tracking_id column in the database table, which causes me lots of issues

If this were to happen again, will the following if statement be enough to capture such an event?

if( !isset($trackingId) || empty($trackingId) || $trackingId == null || $trackingId == "" ) {

    // something is wrong

} else {

    // continue as normal

}
有帮助吗?

解决方案

Use 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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top