2010-02-01 2 views
0

아래에 나열된 일부 PHP 코드가 있습니다. 데이터 입력이 코드의 테스트 중 하나와 일치하지 않는다는 것을 알려주는 함정이 있습니다 ("숟가락이 없습니다"라고 말함, Clever, eh?). 그게 내가 볼 수 것을 어떤 방식으로 드문 일이 아니다, 그 문제에 관해서는,이 함정을 살아 다른 데이터에 완전히 비슷합니다 - - 는 시험의 일치 하나를 수행하는 데이터 때"숟가락이 없습니다"또는 PHP에서 예기치 않은 오류 0xdeadbeef가 발생했습니다

문제는 온다 어쨌든 어떻게 든 통과하게 만든다. 그리고 물론, "예기치 않은 오류"오류는 입력 된 데이터를 출력하여 확실히 확인합니다. 내가 말할 수있는 한, 입력 데이터에는 아무런 문제가 없습니다. 코드와에

 
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 

을 그리고 :

먼저,이 일을 좀 더 쉽게 할 수있는 출력, 이해의

// 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 database 
    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; 
} 
+7

오류 메시지는 영리한 것보다 혼란스러워 보입니다. – gnud

+0

그래, 문구의 의미는 이해하지만 오류 메시지의 의미는 이해하지 못합니다. –

+0

글쎄, 그것은 코드 내에서 검색 할 수있는 고유 한 문자열입니다. "예기치 않은 오류 0x30021812"와 같습니다. – Ernie

답변

2

차라리 인쇄 대신 var_dump()를 사용하십시오 변수의 내용을 표시합니다. 어쩌면 당신이 놓친 앞/뒤 공백이있을 수 있습니다.

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

예. 그것은 트릭을 만들었고, 데이터를 할당 할 때 트림을 만들었습니다. – Ernie

관련 문제