久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

什么會導致 print_r 和/或 var_dump 調試變量失敗?

What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導致 print_r 和/或 var_dump 調試變量失敗?)
本文介紹了什么會導致 print_r 和/或 var_dump 調試變量失敗?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試在 Magento 中調試 PayPal 審核流程.每次我嘗試轉儲以下變量時,我都會得到一個白頁:

I'm attempting to debug the PayPal review process in Magento. Every time I try to dump the following variable I get a white page:

//the variable declaration:
$shippingAddress = $this->getShippingAddress();

//the dump that breaks the page:
 <?php echo '<pre>';print_r($shippingAddress);echo '</pre>'; ?>

我還嘗試在頁面上使用一個變量,該變量用于 if 語句以外的其他內容.

I also tried with a variable on the page that was being used for something other than if statements.

//this variable displays results
<?php echo '<pre>';print_r($billingBlock->setShowAsShippingCheckbox(true)->toHtml());echo '</pre>'; ?>

//however, this one does not:
<?php echo '<pre>';print_r($billingBlock);echo '</pre>'; ?>

我只是想知道什么可能導致我的 var_dump 破壞頁面?如果無法轉儲,我如何查看對象中的內容?

I was just wondering what might cause my var_dump to break the page? How do I see what is in the object if I can't dump it?

推薦答案

首先,PHP 從不只是白頁".當你看到一個空白屏幕時,這意味著 PHP 的執行由于某種原因停止了.但是,除非您的服務器已配置為不記錄錯誤,否則 PHP 錯誤日志或 Magento 異常日志應該會為您提供錯誤信息.

First, PHP never "just white pages". When you get a blank screen, that means PHP's execution has halted fro some reason. However, unless your server has been configured to not log errors, the PHP error log or the Magento exception log should have an error for you.

就您的具體問題而言,Magento 的許多對象都包含對大量信息的引用——有時這些引用是循環的.PHP 的var_dumpprint_r 函數會盲目地遵循這些循環引用并試圖將所有內容打印出來.這最終會導致 PHP 使用比 memory_limit ini 設置允許的更多的內存,并且執行停止.

As far as your specific problem goes, many of Magento's objects contain reference to a large amount of information —?and sometimes the references are circular. PHP's var_dump and print_r functions will blindly follow these circular references and attempt to print everything out. This eventually leads to PHP using more memory than is allowed by the memory_limit ini setting, and execution halts.

大多數 PHP 專業人員使用 xDebug 擴展來解決這個問題.xDebug 擴展有一個修改過的 var_dump,它將限制轉儲的信息量,從而防止上述內存限制問題.如果 xDebug 仍然沒有幫助,xdebug.var_display_max_childrenxdebug.var_display_max_dataxdebug.var_display_max_depth ini 設置是您想要調整的設置與內存限制問題.(一些 PHP 發行版最初將這些設置得太高)

Most PHP professionals use the xDebug extension to work around this. The xDebug extension has a modified var_dump that will limit the amount of information dumped, which prevents the above memory limit problems. The xdebug.var_display_max_children, xdebug.var_display_max_data, and xdebug.var_display_max_depth ini settings are the ones you'll want to tweak if xDebug's still not helping with the memory limit problem. (some PHP distributions have these set too high initially)

如果這不是可能的,那么對 var_dump 稍微小心一點還是有幫助的.

If that's not a possibility, a little caution with your var_dump's can still help.

用它來找出變量類型

var_dump(get_class($thing));

如果它是一個 Magento 對象,使用它來查看它的數據鍵

If it's a Magento object, use this to see its data keys

var_dump(array_keys($thing->getData()));

然后用

var_dump($thing->getData('key_name'));
var_dump($thing->getKeyName()));

這篇關于什么會導致 print_r 和/或 var_dump 調試變量失敗?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Override Magento Config(覆蓋 Magento 配置)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
Magento 404 on Admin Page(管理頁面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價格規則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產品頁面標題以包含屬性)
Magento: adding duties/taxes to a quote during review(Magento:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 99re这里只有精品6 | 91精品国产99久久久久久红楼 | 九九视频这里只有精品 | 99热99| 免费黄色在线 | 欧美日韩国产在线 | 成人午夜视频在线观看 | 免费看毛片网站 | 色女人影院| 免费在线播放av | 国产真实乱人偷精品 | 草草福利影院 | 国产女人18毛片18精品 | 欧美午夜精品一区二区三区 | 免费亚洲视频 | 久久精品欧美一区 | 国产精品国产成人国产三级 | 日韩理论片 | 福利色导航| 最新国产在线视频 | 毛片免费播放 | 成人免费看片在线观看 | 亚洲成人久久久 | 国产精品成人一区二区 | 欧美久久久久久久久久 | 一本在线 | 日韩不卡在线观看 | av观看网站| 大色av| 成人一区在线观看 | 国产三级精品视频 | 久久久不卡| 一色桃子av| 欧美人与性动交α欧美精品 | 国产一区二区精品丝袜 | 中国少妇xxxxhd做受 | 在线欧美| 国产欧美一区二区三区视频在线观看 | 少妇性bbb搡bbb爽爽爽欧美 | 日韩国产在线 | av毛片在线看 |