久久久久久久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:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 亚洲精选一区二区 | 中文字幕在线精品 | 欧美日韩网站 | 99久久国产综合精品麻豆 | 日韩精品专区在线影院重磅 | 久99久视频| 国产精品自拍av | 美女福利视频网站 | 免费在线一区二区 | 国产精品区一区二区三 | 国产精品亚洲一区二区三区在线 | 精品久久久久久久 | 亚洲福利精品 | 无码一区二区三区视频 | 全免费a级毛片免费看视频免费下 | 久久国产精品久久久久久久久久 | 日韩在线一区二区 | 男女视频在线观看免费 | 一区二区三区亚洲 | 做a视频| 在线免费国产 | 亚洲精品自拍视频 | 国产永久免费 | 黑人精品xxx一区一二区 | 一级免费在线视频 | 中文字幕在线精品 | 国产久 | 黄色片视频网站 | 成人精品免费视频 | 久久精品av麻豆的观看方式 | 欧美一区二区三区在线观看 | 亚洲欧美成人在线 | 成人三级在线观看 | 超碰成人免费观看 | 日韩欧美国产精品一区二区 | 色999视频 | 久久国产麻豆 | 99久久精品国产一区二区三区 | 国产欧美一区二区三区在线看 | 久久高清国产视频 | 亚洲视频免费观看 |