snipt

Ctrl+h for KB shortcuts

PHP

Hidden var dump

<?php

function elbone_var_dump($var, $comment = 'var_dump') {
	echo '<!-- '.$comment.' -->'."\n";
	echo '<script data-comment="'.$comment.'">', "\n";
	echo '/*', "\n";
	var_dump($var);
	echo '*/', "\n";
	echo '</script>', "\n";
}

?>

Description

Print debug into into a script tag. Won't execute but allows you to read the array/object/etc
https://snipt.net/embed/d6fb2e0fba3fdb3e78b55debbb4362a0/
/raw/d6fb2e0fba3fdb3e78b55debbb4362a0/
d6fb2e0fba3fdb3e78b55debbb4362a0
php
PHP
12
2019-07-19T15:27:24
True
False
False
Jul 18, 2013 at 01:50 AM
/api/public/snipt/68318/
hidden-var-dump
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">function</span> <span class="nf">elbone_var_dump</span><span class="p">(</span><span class="nv">$var</span><span class="p">,</span> <span class="nv">$comment</span> <span class="o">=</span> <span class="s1">&#39;var_dump&#39;</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">echo</span> <span class="s1">&#39;&lt;!-- &#39;</span><span class="o">.</span><span class="nv">$comment</span><span class="o">.</span><span class="s1">&#39; --&gt;&#39;</span><span class="o">.</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">echo</span> <span class="s1">&#39;&lt;script data-comment=&quot;&#39;</span><span class="o">.</span><span class="nv">$comment</span><span class="o">.</span><span class="s1">&#39;&quot;&gt;&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">echo</span> <span class="s1">&#39;/*&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a> <span class="nb">var_dump</span><span class="p">(</span><span class="nv">$var</span><span class="p">);</span> </span><span id="L-8"><a name="L-8"></a> <span class="k">echo</span> <span class="s1">&#39;*/&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-9"><a name="L-9"></a> <span class="k">echo</span> <span class="s1">&#39;&lt;/script&gt;&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-10"><a name="L-10"></a><span class="p">}</span> </span><span id="L-11"><a name="L-11"></a> </span><span id="L-12"><a name="L-12"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
Debug