【问题标题】:showing variable value with exception message显示带有异常消息的变量值
【发布时间】:2013-01-26 22:32:12
【问题描述】:

我正在尝试通过使用非常基本的方法检查每个阶段的变量/对象来调试发票问题...

我有以下代码

$capOrder = $payment->getOrder();
$capTransID = $capOrder->getPayment()->getLastTransId();

if(!empty($capTransID )){

Mage::throwException(Mage::helper('paygate')->__('zaffar_checking for trans  ID. its not EMPTY'));

}

我的输出看起来像

zaffar_checking 反式 ID。它不是空的

我也想用我的自定义错误消息来回显$capTransID 的值......就像

zaffar_checking 反式 ID。它不是 EMPTY——值为 XXXX

我该怎么做?我无法找到将变量与错误消息组合/连接的方法..

【问题讨论】:

    标签: php debugging magento error-handling


    【解决方案1】:

    改成

    if(!empty($capTransID )){
    
    Mage::throwException(Mage::helper('paygate')->__("zaffar_checking for trans  ID. its not EMPTY--value is $capTransID"));
    
    }
    

    【讨论】:

    • 别这么说:(,我为什么不尝试呢??总是追求复杂性:(
    • 见鬼,我尝试了很多东西,相信我,我什至没有尝试过一次..
    • 只是一个问题,如果我需要回显完整的 OBJECT 像 order 或 payment,我可以用同样的方式显示吗?
    • yw,它不适用于对象,您可以var_dump 对象或使用Mage::log(var_dump($order)) 之类的东西,然后检查日志文件。
    • 是的,它没有显示任何东西,我已经尝试了不止一次,在不同的对象/变量上,有什么想法吗?
    猜你喜欢
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    相关资源
    最近更新 更多