New in Xdebug 2.2: Colours on the command line
来源:互联网 发布:java如何定义一个函数 编辑:程序博客网 时间:2024/05/18 03:15
xdebug安装后,var_dump()不起作用
解决办法:打开 html_error=1
因为通过网页变色,都是通过html css控制的,打开这个属性,var_dump才会起作用
This is the first article in a series about new features in Xdebug 2.2. Besides support for PHP 5.4, there are a few that might be of interest.
Xdebug has overloaded var_dump() with xdebug_var_dump() for a long time and the overloaded function could be configured with a few configuration settings. There is xdebug.var_display_max_data to configure how much of a string should be shown; xdebug.var_display_max_children to configure how many children in an array should be shown and xdebug.var_display_max_depth to configure how many levels "deep" the var_dump()
should go on for. This functionality was available for when PHP had its html_errors setting on as is usually the case in a web environment1.
Xdebug 2.2 adds this same functionality to the non-HTML environment: the command line. Now the overloaded var_dump()
and native xdebug_var_dump()
functions also accept the three aforementioned settings:
derick@whisky:~$ php \ -dxdebug.var_display_max_data=8 \ -dxdebug.var_display_max_children=4 \ -r 'var_dump( "a longer string", array( 1, 2, 3, 4, 5, 6, 7 ) );'
outputs:
string(15) "a longer"...array(7) { [0] => int(1) [1] => int(2) [2] => int(3) [3] => int(4) (more elements)...}
Now, to be fair. This is all a side effect; and merely an add-on to a patch byMichael Maclean. He wrote a patch that adds colours to the output on the command line by using ANSI escape codes. This patch also made the overloaded var_dump()
listen to the limiting settings for variable display. After his patch, the following was the behaviour on the command line as long as stdout is a tty andxdebug.cli_color is set to 1
.
I have extended this so that the settings regarding data display also work without xdebug.cli_color
set to 1
. Further more, in Xdebug 2.2.0RC1, settingxdebug.cli_color
to 2
forces the colours from being shown, even if stdout is not a tty.
Initially, the colour coding of errors and var_dump()
output, would only work on a Unix system where ANSI escape codes are commonly supported. After the release of Xdebug 2.2.0RC1, Chris Jones submitted a bug report suggesting that this functionality could also be available on the Windows console. I wasn't aware that Windows could do this anymore since they dropped ANSI.SYS but apparently there is a tool, ANSICON, that reimplements this. From the next release, Xdebug 2.2.0RC2, Xdebug will now also check whether the ANSICON
environment variable is set, just like Xdebug would check whether stdout is a tty on a Unix platform. As a result, the equivalent console output as shown before looks like the following on Windows (providing ANSICON is installed):
Now the only thing left is adding complete documentation for this feature ;-)
- New in Xdebug 2.2: Colours on the command line
- Create a new repository on the command line/Push an existing repository from the command line
- Using MIT-Scheme in MacOS X on the Command Line
- Running a command on every machine in your domain from the command line
- Working on Command Line
- 【指导】Install Appium on Ubuntu in command line
- The difference between && and ; in the Linux command line
- 4.2.3.1. Using Options on the Command Line
- Lab01 Editing text files on the command line
- Mysql Warning :Using a password on the command line...
- MySQL5.6 Using a password on the command line inte
- open in command line
- Import data in a Lookup Definition from the command-line
- Take screenshots from the command line in Linux
- How to access Dropbox from the command line in Linux
- the diary of sleep jobs & fg command line in linux
- The Command Line!
- The Command-Line Interface
- 将二元树转换成一个排序的双向链表(方法二)
- 2013年(大三)暑假C语言学习笔记
- 人体骨骼坐标在彩色图像中显示
- A+B for Input-Output Practice (V)
- Linux常用命令汇编自结
- New in Xdebug 2.2: Colours on the command line
- 快速排序qsort()函数和二分查找bsearch()函数
- 递归列出目录中的文件列表
- lynx安装及配置
- 快速排序代码复用的方法(未实践)
- js URl传值乱码
- Delphi : keydown与keypress的区别,组合键
- A+B for Input-Output Practice (VI)
- 网络编程Winsock——socket