未定义的变量$ e

时间:2014-10-28 13:59:33

标签: php var

  

[2014年10月28日15:46:22欧洲/布加勒斯特] PHP注意:未定义   变量:e in   /home/lagramad/public_html/discounts/system/modules/gateway/mobilpay/cardRedirect.php   在第226行

     }
catch (Exception $e) {


    echo "\r\n<h3>Plata voucher prin card</h3>\r\n";

if (!($e instanceof Exception)) 
    echo "<p> \r\n\t<form name=\"frmPaymentRedirect\" method=\"post\" action=\"";
    echo $paymentUrl;
    echo "\">\r\n\t<input type=\"hidden\" name=\"env_key\" value=\"";
    echo $objPmReqCard->getEnvKey();
    echo "\"/>\r\n\t<input type=\"hidden\" name=\"data\" value=\"";
    echo $objPmReqCard->getEncData();
    echo "\"/>\r\n\t<p>\r\n\t\tPentru a finaliza plata vei redirectat catre pagina de plati securizata a mobilpay.ro\r\n\t</p>\r\n\t<p>\r\n\t\tDaca nu esti redirectat in 5 secunde apasa <input type=\"image\" src=\"images/12792_mobilpay-96x30.gif\" />\r\n\t</p>\r\n\t</form>\r\n</p>\r\n";

    echo "<script type=\"text/javascript\" language=\"javascript\">\r\n\twindow.setTimeout(document.frmPaymentRedirect.submit(), 5000);\r\n</script>\r\n";
} else {
    echo "<p>";

    echo "<strong>";
    echo $e->getMessage();
    echo "</strong></p>\r\n";
}


echo "\r\n\r\n\r\n";
return 1;


?>

2 个答案:

答案 0 :(得分:1)

如果发生异常,

$e

try {
   throw new Exception('foo');
} catch (Exception $e) {
   // do nothing
}

try {
   $foo = 1; // no exception occurs
} catch (Exception $f) {
   // do nothing
}

var_dump($e); // spits out the exception info
var_dump($f); // undefined variable, because no exception occured to define it

答案 1 :(得分:0)

将你的if语句放在Exception

即。 catch (Exception $e) { if ($e......) { blah vlah blah.... } }