久久久久久久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:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 中文字幕国产日韩 | 黄色免费看 | 国产免费看| 国产精品免费在线 | 成人免费视频观看视频 | 国产精品一区一区 | 国产欧美精品 | 成人免费视频一区 | 国产片侵犯亲女视频播放 | 日韩成人影院在线观看 | 天天操妹子 | 国产成人精品久久 | 亚洲最新网址 | 国产成人免费视频网站视频社区 | 日韩午夜电影在线观看 | 国产精品精品视频一区二区三区 | 婷婷福利视频导航 | 亚洲不卡在线观看 | 久久精品日产第一区二区三区 | 婷婷久| 国产精品久久久久久久久久久久冷 | 99精品国产一区二区三区 | 国产精品欧美精品日韩精品 | 久久日韩精品 | 亚洲天堂影院 | 精品国产一区二区三区免费 | 日韩在线视频一区 | 一道本一区二区 | 亚洲欧美第一视频 | 瑟瑟免费视频 | 91欧美 | 久久婷婷色| 久久亚洲国产 | 天天干视频在线 | 亚洲国产免费 | 亚洲 91| 久久久久久999| 日韩欧美在线免费观看视频 | 日韩精品免费视频 | 亚洲综合日韩精品欧美综合区 | 久久免费观看视频 |