PHP Curl Request Class, Initiating Proper Variables for Request Type? First Time OOP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0












$begingroup$


First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



<?php

// Define Constants, etc.

require_once '../includeclass.php';

class Curl

{
const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

public function get($url, $proxy = NULL)
{
$this->curl = curl_init($url);
$this->proxy = $proxy;
$this->setup($this->proxy);
return $this->request();
}

public function setup($proxy)
{
$this->headers = array();
$this->truncateCookie();

// Gets Random UserAgent (not included in post/review)
$this->ua = $this->getUA();
if ($proxy !== NULL)
{
$this->proxy = explode(':', $proxy) [0];
$this->proxyport = explode(':', $proxy) [1];
curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);
}

curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($this->curl, CURLOPT_ENCODING, 1);
curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Language:en-US,en;q=0.9',
'Cache-Control: max-age=0',
'Connection: keep-alive',
'Host: example.com'
));
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
$this,
'headerCallback'
));
}

public function truncateCookie()
{
$cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
$opencookiefile = @fopen($cookie, "r+");
if ($opencookiefile !== false)
{
ftruncate($opencookiefile, 0);
fclose($opencookiefile);
}
}

public function headerCallback($curl, $header)
{
$this->headers = $header;
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) return $len;
$name = strtolower(trim($header[0]));
if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
else $this->headers[$name] = trim($header[1]);
return $len;
}

public function request()
{
$this->curldata = curl_exec($this->curl);
$curlinfo = curl_getinfo($this->curl);
$respTime = $curlinfo['connect_time'];
$httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

// Condition to Ensure curldata returns HTML
if (preg_match("//[a-z]*>/i", $this->curldata) != 0) {
// Condition to match download_size vs downloaded_size to ensure curl completed
// entire request in full (only applicable on some URLs that do
// not have any encoding in headers and actually show the
// content-length in retrieved headers/headers array
if (isset($this->headers['content-length'][0]))
{
$download_size = (int)$this->headers['content-length'][0];
$downloaded_size = strlen($this->curldata);
if ($httpcode === 200 && $download_size === $downloaded_size)
{
curl_close($this->curl);
return $this->curldata;
}
}

if ($httpcode === 200)
{
curl_close($this->curl);
return $this->curldata;
}
}

echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
curl_close($this->curl);
return false;
}

// Extra I'm including, not shown in example below
// Recursive Loop to Retry Curl Request until a Valid Response
// (still need to modify to create a max attempts condition..)

public function curlLoop(curl $curl, $url)
{
$count = 0;
while (true)
{
$count++;
echo "rnrn#" . $count . ": " . $url . "rnrn";
outputFlush();
$html = $curl->get($url);
if ($html !== false)
{
break;
}
}

return $html;
}

// end Class
}


And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



$curl = new Curl();
$resp = $curl->get($url, $proxy);
if ($resp === FALSE) {
//curl response failed
return false;
}
else {
// do whatever, successful curl response --- $resp = $this->curldata


Happy with this so far, the code works as shown.
Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



As discussed in my comments in the class, some conditions are only applicable to certain URLs.



As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










share|improve this question









$endgroup$



















    0












    $begingroup$


    First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



    <?php

    // Define Constants, etc.

    require_once '../includeclass.php';

    class Curl

    {
    const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

    public function get($url, $proxy = NULL)
    {
    $this->curl = curl_init($url);
    $this->proxy = $proxy;
    $this->setup($this->proxy);
    return $this->request();
    }

    public function setup($proxy)
    {
    $this->headers = array();
    $this->truncateCookie();

    // Gets Random UserAgent (not included in post/review)
    $this->ua = $this->getUA();
    if ($proxy !== NULL)
    {
    $this->proxy = explode(':', $proxy) [0];
    $this->proxyport = explode(':', $proxy) [1];
    curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
    curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);
    }

    curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($this->curl, CURLOPT_ENCODING, 1);
    curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
    curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
    curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
    curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
    curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
    'Accept-Language:en-US,en;q=0.9',
    'Cache-Control: max-age=0',
    'Connection: keep-alive',
    'Host: example.com'
    ));
    curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
    $this,
    'headerCallback'
    ));
    }

    public function truncateCookie()
    {
    $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
    $opencookiefile = @fopen($cookie, "r+");
    if ($opencookiefile !== false)
    {
    ftruncate($opencookiefile, 0);
    fclose($opencookiefile);
    }
    }

    public function headerCallback($curl, $header)
    {
    $this->headers = $header;
    $len = strlen($header);
    $header = explode(':', $header, 2);
    if (count($header) < 2) return $len;
    $name = strtolower(trim($header[0]));
    if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
    else $this->headers[$name] = trim($header[1]);
    return $len;
    }

    public function request()
    {
    $this->curldata = curl_exec($this->curl);
    $curlinfo = curl_getinfo($this->curl);
    $respTime = $curlinfo['connect_time'];
    $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

    // Condition to Ensure curldata returns HTML
    if (preg_match("//[a-z]*>/i", $this->curldata) != 0) {
    // Condition to match download_size vs downloaded_size to ensure curl completed
    // entire request in full (only applicable on some URLs that do
    // not have any encoding in headers and actually show the
    // content-length in retrieved headers/headers array
    if (isset($this->headers['content-length'][0]))
    {
    $download_size = (int)$this->headers['content-length'][0];
    $downloaded_size = strlen($this->curldata);
    if ($httpcode === 200 && $download_size === $downloaded_size)
    {
    curl_close($this->curl);
    return $this->curldata;
    }
    }

    if ($httpcode === 200)
    {
    curl_close($this->curl);
    return $this->curldata;
    }
    }

    echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
    curl_close($this->curl);
    return false;
    }

    // Extra I'm including, not shown in example below
    // Recursive Loop to Retry Curl Request until a Valid Response
    // (still need to modify to create a max attempts condition..)

    public function curlLoop(curl $curl, $url)
    {
    $count = 0;
    while (true)
    {
    $count++;
    echo "rnrn#" . $count . ": " . $url . "rnrn";
    outputFlush();
    $html = $curl->get($url);
    if ($html !== false)
    {
    break;
    }
    }

    return $html;
    }

    // end Class
    }


    And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



    $curl = new Curl();
    $resp = $curl->get($url, $proxy);
    if ($resp === FALSE) {
    //curl response failed
    return false;
    }
    else {
    // do whatever, successful curl response --- $resp = $this->curldata


    Happy with this so far, the code works as shown.
    Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



    As discussed in my comments in the class, some conditions are only applicable to certain URLs.



    As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
    I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



    Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



    Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



    Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










    share|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



      <?php

      // Define Constants, etc.

      require_once '../includeclass.php';

      class Curl

      {
      const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

      public function get($url, $proxy = NULL)
      {
      $this->curl = curl_init($url);
      $this->proxy = $proxy;
      $this->setup($this->proxy);
      return $this->request();
      }

      public function setup($proxy)
      {
      $this->headers = array();
      $this->truncateCookie();

      // Gets Random UserAgent (not included in post/review)
      $this->ua = $this->getUA();
      if ($proxy !== NULL)
      {
      $this->proxy = explode(':', $proxy) [0];
      $this->proxyport = explode(':', $proxy) [1];
      curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
      curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);
      }

      curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
      curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
      curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($this->curl, CURLOPT_ENCODING, 1);
      curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
      curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
      curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
      'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
      'Accept-Language:en-US,en;q=0.9',
      'Cache-Control: max-age=0',
      'Connection: keep-alive',
      'Host: example.com'
      ));
      curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
      $this,
      'headerCallback'
      ));
      }

      public function truncateCookie()
      {
      $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
      $opencookiefile = @fopen($cookie, "r+");
      if ($opencookiefile !== false)
      {
      ftruncate($opencookiefile, 0);
      fclose($opencookiefile);
      }
      }

      public function headerCallback($curl, $header)
      {
      $this->headers = $header;
      $len = strlen($header);
      $header = explode(':', $header, 2);
      if (count($header) < 2) return $len;
      $name = strtolower(trim($header[0]));
      if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
      else $this->headers[$name] = trim($header[1]);
      return $len;
      }

      public function request()
      {
      $this->curldata = curl_exec($this->curl);
      $curlinfo = curl_getinfo($this->curl);
      $respTime = $curlinfo['connect_time'];
      $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

      // Condition to Ensure curldata returns HTML
      if (preg_match("//[a-z]*>/i", $this->curldata) != 0) {
      // Condition to match download_size vs downloaded_size to ensure curl completed
      // entire request in full (only applicable on some URLs that do
      // not have any encoding in headers and actually show the
      // content-length in retrieved headers/headers array
      if (isset($this->headers['content-length'][0]))
      {
      $download_size = (int)$this->headers['content-length'][0];
      $downloaded_size = strlen($this->curldata);
      if ($httpcode === 200 && $download_size === $downloaded_size)
      {
      curl_close($this->curl);
      return $this->curldata;
      }
      }

      if ($httpcode === 200)
      {
      curl_close($this->curl);
      return $this->curldata;
      }
      }

      echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
      curl_close($this->curl);
      return false;
      }

      // Extra I'm including, not shown in example below
      // Recursive Loop to Retry Curl Request until a Valid Response
      // (still need to modify to create a max attempts condition..)

      public function curlLoop(curl $curl, $url)
      {
      $count = 0;
      while (true)
      {
      $count++;
      echo "rnrn#" . $count . ": " . $url . "rnrn";
      outputFlush();
      $html = $curl->get($url);
      if ($html !== false)
      {
      break;
      }
      }

      return $html;
      }

      // end Class
      }


      And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



      $curl = new Curl();
      $resp = $curl->get($url, $proxy);
      if ($resp === FALSE) {
      //curl response failed
      return false;
      }
      else {
      // do whatever, successful curl response --- $resp = $this->curldata


      Happy with this so far, the code works as shown.
      Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



      As discussed in my comments in the class, some conditions are only applicable to certain URLs.



      As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
      I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



      Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



      Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



      Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.










      share|improve this question









      $endgroup$




      First time creating and constructing a PHP Object Class from scratch/near-scratch. Currently not using any pre-built class frameworks (although highly considering using an already constructed class like php-curl-class as a composer dependency down the line).



      <?php

      // Define Constants, etc.

      require_once '../includeclass.php';

      class Curl

      {
      const cookieJar = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';

      public function get($url, $proxy = NULL)
      {
      $this->curl = curl_init($url);
      $this->proxy = $proxy;
      $this->setup($this->proxy);
      return $this->request();
      }

      public function setup($proxy)
      {
      $this->headers = array();
      $this->truncateCookie();

      // Gets Random UserAgent (not included in post/review)
      $this->ua = $this->getUA();
      if ($proxy !== NULL)
      {
      $this->proxy = explode(':', $proxy) [0];
      $this->proxyport = explode(':', $proxy) [1];
      curl_setopt($this->curl, CURLOPT_PROXY, $this->proxy);
      curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyport);
      }

      curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 60);
      curl_setopt($this->curl, CURLOPT_TIMEOUT, 300);
      curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
      curl_setopt($this->curl, CURLOPT_ENCODING, 1);
      curl_setopt($this->curl, CURLOPT_COOKIESESSION, 1);
      curl_setopt($this->curl, CURLOPT_COOKIEJAR, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_COOKIEFILE, self::cookieJar);
      curl_setopt($this->curl, CURLOPT_USERAGENT, $this->ua);
      curl_setopt($this->curl, CURLOPT_HTTPHEADER, array(
      'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
      'Accept-Language:en-US,en;q=0.9',
      'Cache-Control: max-age=0',
      'Connection: keep-alive',
      'Host: example.com'
      ));
      curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(
      $this,
      'headerCallback'
      ));
      }

      public function truncateCookie()
      {
      $cookie = ROOT_DIR . DS . 'assets' . DS . 'cookie.txt';
      $opencookiefile = @fopen($cookie, "r+");
      if ($opencookiefile !== false)
      {
      ftruncate($opencookiefile, 0);
      fclose($opencookiefile);
      }
      }

      public function headerCallback($curl, $header)
      {
      $this->headers = $header;
      $len = strlen($header);
      $header = explode(':', $header, 2);
      if (count($header) < 2) return $len;
      $name = strtolower(trim($header[0]));
      if (!array_key_exists($name, $this->headers)) $this->headers[$name] = [trim($header[1]) ];
      else $this->headers[$name] = trim($header[1]);
      return $len;
      }

      public function request()
      {
      $this->curldata = curl_exec($this->curl);
      $curlinfo = curl_getinfo($this->curl);
      $respTime = $curlinfo['connect_time'];
      $httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);

      // Condition to Ensure curldata returns HTML
      if (preg_match("//[a-z]*>/i", $this->curldata) != 0) {
      // Condition to match download_size vs downloaded_size to ensure curl completed
      // entire request in full (only applicable on some URLs that do
      // not have any encoding in headers and actually show the
      // content-length in retrieved headers/headers array
      if (isset($this->headers['content-length'][0]))
      {
      $download_size = (int)$this->headers['content-length'][0];
      $downloaded_size = strlen($this->curldata);
      if ($httpcode === 200 && $download_size === $downloaded_size)
      {
      curl_close($this->curl);
      return $this->curldata;
      }
      }

      if ($httpcode === 200)
      {
      curl_close($this->curl);
      return $this->curldata;
      }
      }

      echo "rnrn" . "Failed: " . curl_errno($this->curl) . "rnrn";
      curl_close($this->curl);
      return false;
      }

      // Extra I'm including, not shown in example below
      // Recursive Loop to Retry Curl Request until a Valid Response
      // (still need to modify to create a max attempts condition..)

      public function curlLoop(curl $curl, $url)
      {
      $count = 0;
      while (true)
      {
      $count++;
      echo "rnrn#" . $count . ": " . $url . "rnrn";
      outputFlush();
      $html = $curl->get($url);
      if ($html !== false)
      {
      break;
      }
      }

      return $html;
      }

      // end Class
      }


      And I'm using it like such (only thing functions shown doesn't hit on is my curlLoop function, which I included just for fun mostly (still needs to work, so not particularly relevant for Review):



      $curl = new Curl();
      $resp = $curl->get($url, $proxy);
      if ($resp === FALSE) {
      //curl response failed
      return false;
      }
      else {
      // do whatever, successful curl response --- $resp = $this->curldata


      Happy with this so far, the code works as shown.
      Couple of setbacks/issues I'm having, major point being (and question in point from title), how would I best manage/account for the myriad of different URLs being passed through?



      As discussed in my comments in the class, some conditions are only applicable to certain URLs.



      As of right now, my Class is unsupported if the content-length header is shown and the curl response has encoded request headers (which makes strlen($this->curldata); a few kb bit less than what the headers display).
      I want this here, as it has saved me a few times where the curl response was 200 but the request for some reason failed/did not download entirely.



      Additionally, I'm a bit perplexed on how to add conditions for the proper headers. As you can see, the headers are hardwired to the url example.com for all requests. This is of course a big issue as headers should be appropriated to certain URLs.



      Lastly, the blanket public statement for all methods in the class is an obvious issue. I still need to go over method visibilities and do some testing, so comment on this or not.



      Any reviews/comments very much appreciated.. mostly learning as I go so progress can be a bit rocky at times.







      php object-oriented curl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 15 mins ago









      Brian BrumanBrian Bruman

      1134




      1134






















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216959%2fphp-curl-request-class-initiating-proper-variables-for-request-type-first-time%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216959%2fphp-curl-request-class-initiating-proper-variables-for-request-type-first-time%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Список кардиналов, возведённых папой римским Каликстом III

          Deduzione

          Mysql.sock missing - “Can't connect to local MySQL server through socket”