laravel 为什么我的调试数据未格式化?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17009465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:55:34  来源:igfitidea点击:

Why is my debug data unformatted?

phplaravellaravel-4

提问by krissanawat

var_dumpand print_rare displayed are not formatted when using Laravel 4. How do I format the data to be more readable?

var_dumpprint_r使用 Laravel 4 时,显示和显示未格式化。如何格式化数据以提高可读性?

回答by Antonio Carlos Ribeiro

Add Kint to your composer.json by running this on the command line:

通过在命令行上运行将 Kint 添加到您的 composer.json:

composer require raveren/kint "dev-master"

And then try it:

然后试试看:

dd( new Controller );

You should see this:

你应该看到这个:

enter image description here

在此处输入图片说明

Better, huh?

更好吧?

回答by Krucamper

Use kint

使用kint

we use should s()instead of print_r()

我们使用 should s()而不是print_r()

use should d()instead of var_dump()

使用 should d()而不是var_dump()

ex: sd($arr); like same print_r($arr); die();

例如:sd($arr); 像同样的 print_r($arr); 死();

Ref: http://raveren.github.io/kint/#configuration

参考:http: //raveren.github.io/kint/#configuration

回答by someone44

You can use the pretag to format align your answear http://www.w3schools.com/tags/tag_pre.asp

您可以使用pre标签来格式化您的 answear http://www.w3schools.com/tags/tag_pre.asp