php 调试值辅助函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 调试值辅助函数相关的知识,希望对你有一定的参考价值。

<span style="color: #000000; font-weight: bold;">function</span> dval<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$val</span>, <span style="color: #0000ff;">$print</span>=<span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #0000ff;">$method</span>=<span style="color: #ff0000;">'var_export'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
&nbsp;
    <span style="color: #808080; font-style: italic;">// dval = Debug a VALue -&gt; easy to remember for me</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$method</span> == <span style="color: #ff0000;">'var_export'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$r</span> = <a href="http://www.php.net/var_export"><span style="color: #000066;">var_export</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$val</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$r</span> = <a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$val</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$print</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;&lt;pre&gt;[[&quot;</span> . <a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$r</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;]]&lt;/pre&gt;&quot;</span>; <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&lt;pre&gt;[[&quot;</span> . <a href="http://www.php.net/htmlspecialchars"><span style="color: #000066;">htmlspecialchars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$r</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;]]&lt;/pre&gt;&quot;</span>; <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>

以上是关于php 调试值辅助函数的主要内容,如果未能解决你的问题,请参考以下文章

php--一些有用的Laravel辅助函数

PHP代码审计1-审计环境与调试函数

php变量调试辅助

Bool 方法返回错误值

php PHP辅助函数(WP)

php 示例SVG和Markdown辅助函数#laravel #php