snipt

Ctrl+h for KB shortcuts

PHP

Makes directory if it doesn't exist

1
2
3
4
// The following line if you want to make the directory if it doesn't exist
$targetPath = YOUR TARGET PATH
if(!file_exists(str_replace('//','/',$targetPath))) {						mkdir(str_replace('//','/',$targetPath), 0775, true);
}
https://snipt.net/embed/e1b564d05b227faa4506c52302a9cdae/
/raw/e1b564d05b227faa4506c52302a9cdae/
e1b564d05b227faa4506c52302a9cdae
php
PHP
4
2019-08-22T12:12:13
True
False
False
/api/public/snipt/28426/
makes-directory-if-it-doesnt-exist
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">// The following line if you want to make the directory if it doesn&#39;t exist</span> </span><span id="L-2"><a name="L-2"></a><span class="x">$targetPath = YOUR TARGET PATH</span> </span><span id="L-3"><a name="L-3"></a><span class="x">if(!file_exists(str_replace(&#39;//&#39;,&#39;/&#39;,$targetPath))) { mkdir(str_replace(&#39;//&#39;,&#39;/&#39;,$targetPath), 0775, true);</span> </span><span id="L-4"><a name="L-4"></a><span class="x">}</span> </span></pre></div> </td></tr></table>
php

PHP

For our MSI sites to know whether to show testing items or not.

1
2
3
4
5
6
7
8
function msitest() {
     if(isset($_GET['msitest'])) {
        return true;
     }
     else {
        return false;
     }
}
https://snipt.net/embed/b6421543abda7397995045ccc4af971d/
/raw/b6421543abda7397995045ccc4af971d/
b6421543abda7397995045ccc4af971d
php
PHP
8
2019-08-19T11:06:03
True
False
False
/api/public/snipt/27533/
for-our-msi-sites-to-know-whether-to-show-testing-items-or-not
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">function msitest() {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> if(isset($_GET[&#39;msitest&#39;])) {</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> return true;</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> }</span> </span><span id="L-5"><a name="L-5"></a><span class="x"> else {</span> </span><span id="L-6"><a name="L-6"></a><span class="x"> return false;</span> </span><span id="L-7"><a name="L-7"></a><span class="x"> }</span> </span><span id="L-8"><a name="L-8"></a><span class="x">}</span> </span></pre></div> </td></tr></table>
msi, php, wordpress

PHP

Prints out print_r in a readable format

1
2
3
4
5
6
// PRINTS OUT PRINT_R REALLY PRETTY
function print_r_html ($arr) {
        ?><pre><?
        print_r($arr);
        ?></pre><?
}
https://snipt.net/embed/99a15bb788a27cb61f7fc75da5a40e5b/
/raw/99a15bb788a27cb61f7fc75da5a40e5b/
99a15bb788a27cb61f7fc75da5a40e5b
php
PHP
7
2019-08-23T09:35:27
True
False
False
/api/public/snipt/17578/
prints-out-print_r-in-a-readable-format
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">// PRINTS OUT PRINT_R REALLY PRETTY</span> </span><span id="L-2"><a name="L-2"></a><span class="x">function print_r_html ($arr) {</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> ?&gt;&lt;pre&gt;</span><span class="cp">&lt;?</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">print_r</span><span class="p">(</span><span class="nv">$arr</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="cp">?&gt;</span><span class="x">&lt;/pre&gt;</span><span class="cp">&lt;?</span> </span><span id="L-6"><a name="L-6"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
function, php