2020-07-08 17:19:13 +03:00

19 lines
826 B
HTML

<h1>PHP</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from PHP.</p>
<div class="highlight"><pre><span></span><code><span class="x">file_get_contents(&#39;PING_URL&#39;);</span>
</code></pre></div>
<p>If you would like to setup timeout and retry options, as discussed in the
<a href="../reliability_tips/">reliability tips section</a>, there is a
<a href="https://www.phpcurlclass.com/">curl package</a> available that lets you do that easily:</p>
<div class="highlight"><pre><span></span><code><span class="x">use Curl\Curl;</span>
<span class="x">$curl = new Curl();</span>
<span class="x">$curl-&gt;setRetry(20);</span>
<span class="x">$curl-&gt;setTimeout(5);</span>
<span class="x">$curl-&gt;get(&#39;PING_URL&#39;);</span>
</code></pre></div>
<p>Note: this code does not throw any exceptions.</p>