久久久久久久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_children、xdebug.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:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 久在线| 国产一级一片免费播放 | 欧美一二区 | 亚洲欧美综合精品另类天天更新 | 日本亚洲一区 | 91文字幕巨乱亚洲香蕉 | 中文字幕第100页 | 久久aⅴ乱码一区二区三区 91综合网 | 亚洲欧美精| 国产一区二区三区日韩 | 国产91中文 | 深夜福利影院 | 一区二区三区在线免费 | 欧美精品久久久久久久久久 | 亚洲久久一区 | 日韩看片 | 亚洲精品播放 | 91五月婷蜜桃综合 | 精品久久香蕉国产线看观看亚洲 | 亚洲 中文 欧美 日韩 在线观看 | 国产精品观看 | 男人的天堂在线视频 | 又黑又粗又长的欧美一区 | 亚洲精品乱码久久久久久久久久 | 成年人网站国产 | 精品久久久久久久久久久久久久 | 欧美天堂 | 天天搞天天操 | 亚洲精品乱码久久久久久9色 | 极品国产视频 | 福利片在线观看 | 在线播放亚洲 | 中文精品久久 | 国产伦一区二区三区四区 | 亚洲九色 | 国产精品揄拍一区二区 | 久久综合一区二区 | 一区二区三区精品在线视频 | 天天操夜夜拍 | 天天操网 | 久久久91精品国产一区二区三区 |