开发者

"There is no spoon" or: Unexpected error 0xdeadbeef in PHP

I have some PHP code, listed below. I have a trap that tells me if the data input does not match any of the tests in the code ("There is no spoon", it says. Clever, eh?).

The trouble comes when data - that isn't unusual in any way that I can see, and for that matter, is completely similar to other data that survives this trap - that does match one of the tests somehow makes it through anyway. And of course, the "unexpected error" error outputs the data that was input, just to make sure. As far as I can tell, that input data has nothing wrong with it.

First, there's the output, which might make things a little easier to understand:

Customer XXXXXXXXXXXX, DID XXXXX2515  has been billed already for 2010-01.
Deleting last billing from database before continuing.
This DID is a Toll Free Number.
Trunkrate is therefore: 0.05
Starting billing for DID XXXXXX2515
Trunkrate: 0.05 Type: TFN

2010-01-22 15:45:15: billsecs: 22 billMin: 1 Source: XXXXXX0808 Destination: XXXXXX2515
Error 34: There is no spoon.
Source: XXXXXX0808 Destination: XXXXXX2515 Did: XXXXXX2515  Type: TFN

2010-01-12 14:49:41: billsecs: 55 billMin: 1 Source: 0000000000 Destination: XXXXXX2515
Error 34: There is no spoon.
Source: 0000000000 Destination: XXXXXX2515 Did: XXXXXX2515  Type: TFN

2010-01-12 11:46:45: billsecs: 6 billMin: 1 Source: XXXXXX8689 Destination: XXXXXX2515
Error 34: There is no spoon.
Source: XXXXXX8689 Destination: XXXXXX2515 Did: XXXXXX2515  Type: TFN

2010-01-08 12:56:57: billsecs: 610 billMin: 11 Source: XXXXXX2515 Destination: 1XXXXXX0798
Error 34: There is no spoon.
Source: XXXXXX2515 Destination: 1XXXXXX0798 Did: XXXXXX2515  Type: TFN

2010-01-07 11:01:49: billsecs: 17 billMin: 1 Source: XXXXXX2515 Destination: 011XXXXXXX41022
Error 34: There is no spoon.
Source: XXXXXX2515 Destination: 011XXXXXXX41022 Did: XXXXXX2515  Type: TFN

2010-01-05 11:20:24: billsecs: 7 billMin: 1 Source: XXXXXX0928 Destination: XXXXXX2515
Error 34: There is no spoon.
Source: XXXXXX0928 Destination: XXXXXX2515 Did: XXXXXX2515  Type: TFN

And, on with the code:

// If the call is incoming, just charge the trunk rate.
if ($thisCall['dst'] == $did && $type == "IAX") {
    $ldrate = 0;
    $location = "British Columbia";
    $calltype = "NALD";

if ($debug) print "Incoming call to IAX trunk.\n";

// Incoming calls to TFNs
} elseif ($thisCall['dst'] == $did && $type == "TFN") {

    $ldrate = 0;
    $location = "Toll-Free";
    $calltype = "NALD";

// If the call is outgoing, check to see if it's local
} elseif ($thisCall['src'] == $did) {

    // If the outgoing call is local, just charge the trunk rate
    // In this case, src is our customer, dst is remote end
    if (callIsLocal($thisCall['src'], $thisCall['dst'])) {
        $ldrate = 0;
        $location = "British Columbia";
        $calltype = "NALD";
    }

    // If the outgoing call is long distance, get the rate from the datab开发者_如何学Goase
    else {
        $ratearr = getRate($thisCall['dst']);

        $ldrate = $ratearr['ldrate'];
        $location = $ratearr['location'];
        $calltype = $ratearr['calltype'];

        if ($debug) print "LDrate: $ldrate, Location: $location, Calltype: $calltype\n";
    }
} else {
    print "Error 34: There is no spoon.\n";
    print "Source: " . $thisCall['src'] . " Destination: " . $thisCall['dst'];
    print " Did: $did Type: $type\n ";
    continue;
}


I'd rather use var_dump() instead of print to display the content of the variables. Maybe there's a leading/trailing whitespace that you've missed.

else {
  print "Error 34: There is no spoon.\n";
  print "Source="; var_dump($thisCall['src']);
  print "Destination="; var_dump($thisCall['dst']);
  print "did="; var_dump($did);
  print "Type="; var_dump($type);
  continue;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜