最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】VSCode调试PHP时无法显示长字符串变量完整值

PHP crifan 4737浏览 0评论

折腾:

【未解决】php中用正则过滤html中code中多余span标签

期间,用VSCode去调试PHP期间,发现个问题:

对于变量的值,如果很长的话,右键拷贝出来的值,只有一部分,不是完整的字符串:

鼠标移动上去显示出来的效果:

内容不完整

右键复制出来的值,依旧不完整:

"<div><br /></div><div>此处包含要测试的内容,包括code代码:</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;"><div><span style="font-size: 12px; font-family: Monaco;">some code include</span></div><div><span style="font-size: 12px; font-family: Monaco;">little &lt;</span></div><div><span style="font-size: 12px; font-family: Monaco;">greater &gt;</span></div><div><span style="font-size: 12px; font-family: Monaco;">at &amp;</span></div><div><span style="font-size: 12px; font-family: Monaco;">和其他字符</span></div></div><div>希望同步后,不要:</div><div>有多余的code</div><div>html字符不要被转义</div><div><br /></div><div>另外再去�"

少了后面很多内容。

希望能显示或获取到完整的值

vscode get variable full value

typescript – How to display current values of VS Code’s predefined variables (such as “${workspaceFolder}”)? – Stack Overflow

vscode debug show variable full value

Variable gets truncated · Issue #260 · felixfbecker/vscode-php-debug

Please refer to the XDebug documentation, the adapter doesn’t truncate it, it’s XDebug. You can customize XDebug settings through launch.json. They get truncated because else big variables can easily slow down the debugger.

说是XDebug的问题

试试:

      "xdebugSettings": {
        "max_data": -1,
        "max_children": -1
      }

重启调试php,效果是:

果然显示完整的值了

然后再去拷贝出来

也是完整的值了:

"<div><br /></div><div>此处包含要测试的内容,包括code代码:</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;"><div><span style="font-size: 12px; font-family: Monaco;">some code include</span></div><div><span style="font-size: 12px; font-family: Monaco;">little &lt;</span></div><div><span style="font-size: 12px; font-family: Monaco;">greater &gt;</span></div><div><span style="font-size: 12px; font-family: Monaco;">at &amp;</span></div><div><span style="font-size: 12px; font-family: Monaco;">和其他字符</span></div></div><div>希望同步后,不要:</div><div>有多余的code</div><div>html字符不要被转义</div><div><br /></div><div>另外再去看看,之前出bug的代码</div><div>好像是中间包含多个空行?的代码</div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);-en-codeblock:true;"><div># Author: Crifan Li</div><div># Function: Batch make for all gitbooks</div><div># Version: 20190716</div><div>#</div><div># [Note]</div><div># 1. this makefile should be located in</div><div># /Users/crifan/dev/dev_root/gitbook/gitbook_src_root/common</div><div><div><br /></div><div><br /></div></div><div><div>SUB_BOOKS=$(shell ls ../books)</div><div><br /></div></div><div><div>BOOKS_SRC_ROOT=$(shell cd ../books &amp;&amp; pwd)</div><div><br /></div></div><div><div><br /></div><div><br /></div></div><div># Batch make for all gitbooks</div><div><div>help debug_dir init sync_content clean_all website pdf epub mobi all upload commit deploy:</div><div><br /></div></div><div>  @echo "Current path="`pwd`;</div><div>  @echo "LS_OUTPUT="$(SUB_BOOKS);</div><div>  @echo "BOOKS_SRC_ROOT="$(BOOKS_SRC_ROOT);</div><div><div>  @for each_item in $(SUB_BOOKS); \</div><div><br /></div></div><div><div>  do \</div><div><br /></div></div><div><div>    if [ -d $(BOOKS_SRC_ROOT)/$$each_item ]; then \</div><div><br /></div></div><div><div>      cd $(BOOKS_SRC_ROOT)/$$each_item; \</div><div><br /></div></div><div><div>      echo `pwd`; \</div><div><br /></div></div><div><div>      if [ -f Makefile ]; then \</div><div><br /></div></div><div><div>        make $@ || exit "$$?"; \</div><div><br /></div></div><div><div>      fi; \</div><div><br /></div></div><div><div>      cd ..; \</div><div><br /></div></div><div><div>    fi; \</div><div><br /></div></div><div>  done;</div></div><div>看看效果</div><div><br /></div>"

【总结】

此处,VSCode调试php代码时,鼠标移动到变量上,显示出变量值

但是由于值是很长的字符串,导致没有显示完整

解决办法:

此处Php的调试是用的XDebug,去给.vscode/launch.json中的 Listen for XDebug中增加配置:

      "xdebugSettings": {
        "max_data": -1,
        "max_children": -1
      }

即可。

转载请注明:在路上 » 【已解决】VSCode调试PHP时无法显示长字符串变量完整值

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.182 seconds, using 22.08MB memory