title: Fatal error: Call to undefined function in PHP
body: <p>I have the following code for the payment section of PHP website</p>
  
  <pre><code>if (isset($_POST['Confirm'])) {
  
    $payment = $_SESSION['payment'];
    $paymode = checkpaymentmode($payment); //get paymentmode code
    $mtxcd = getmtxcd(); //merchant transaction code
  
  
    if (!function_exists('checkpaymentmode')) {
          function checkpaymentmode($payment) {
              if ($payment == 'Amex') {
                  return "A";
              } elseif ($payment == 'Direc-Debit') {
                  return "D";
              } else {
                  return "C";
              } //assume the rest are visa/master
          }
  
      }
  
  }
  </code></pre>
  
  <p>This code is the part one confirmation page. After confirmation, execute these codes. Am using some other functions in this page along with this function. I comment this one and try with others, got same error with all functions. </p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function checkpaymentmode() in line33..</p>
  </blockquote>
  
  <p>Any solution for this??</p>