/raw/025b58161eb18a6417782d4d290f23a4/
025b58161eb18a6417782d4d290f23a4
text
Text only
6
2025-04-04T11:35:19
True
False
False
/api/public/snipt/146985/
angular-ajax-post-to-php
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$headers = apache_request_headers();
</span><span id="L-2"><a name="L-2"></a>if (empty($headers['Content-Length'])) exit;
</span><span id="L-3"><a name="L-3"></a>
</span><span id="L-4"><a name="L-4"></a>$input = file_get_contents('php://input');
</span><span id="L-5"><a name="L-5"></a>$post_object = json_decode($input);
</span></pre></div>
</td></tr></table>