Re: Pass variable to pcntl_fork child

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/2/2014 11:11 AM, Christoph Becker wrote:
Jim Giner wrote:

On 7/2/2014 5:40 AM, Uggla Henrik wrote:

      $call = str_replace('@@', '&', $_GET['call']);

      if ($pid = pcntl_fork())
      {
          $previousCalls=file("calls.txt", FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES);
          if (!in_array($call, $previousCalls))
          {
              file_put_contents("calls.txt", $call."\n", FILE_APPEND);
          }
      }
      else
      {
          function displayUrl($url)
          {
              $ch = curl_init($url);
              curl_setopt ( $ch, CURLOPT_HEADER, 1);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              $curlResult = curl_exec($ch);
              curl_close($ch);
              list($headers,$content) = explode("\r\n\r\n",$curlResult,2);
              foreach (explode("\r\n",$headers) as $hdr)
              {
                  if ($hdr != 'Transfer-Encoding: chunked')
                  {
                      header($hdr);
                  }
              }
              echo $content;
          }
          displayUrl($call);
      }

1 What's a child?

In this case a child process, see
<http://www.php.net/manual/en/function.pcntl-fork.php>.

2 You must use == in your if condition.

In this case that would be wrong, see
<http://www.php.net/manual/en/function.pcntl-fork.php>.

So I see....

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux