zoukankan      html  css  js  c++  java
  • php双线程操作

    <?php
    function runThread()
    {
    $fp = fsockopen('localhost', 80, $errno, $errmsg);

    fputs($fp, "GET /test/doublethread.php?act=b\r\n\r\n"); //这里的第二个参数是HTTP协议中规定的请求头
    //不明白的请看RFC中的定义

    fclose($fp);
    }

    function a()
    {
    $fp = fopen('result_a.log', 'w');
    fputs($fp, 'Set in ' . Date('h:i:s', time()) . (double)microtime() . "\r\n");

    fclose($fp);
    }

    function b()
    {
    print_R(123);exit;
    $fp = fopen('result_b.log', 'w');
    fputs($fp, 'Set in ' . Date('h:i:s', time()) . (double)microtime() . "\r\n");

    fclose($fp);
    }

    if(!isset($_GET['act'])) $_GET['act'] = 'a';

    if($_GET['act'] == 'a')
    {
    runThread();
    a();
    }
    else if($_GET['act'] == 'b') b();
    ?>

  • 相关阅读:
    基础
    基础
    基础
    基础
    基础
    基础
    基础
    基础
    Gym102361A Angle Beats(直角三角形 计算几何)题解
    Petrozavodsk Summer Training Camp 2016H(多标记线段树)题解
  • 原文地址:https://www.cnblogs.com/hechunhua/p/3069156.html
Copyright © 2011-2022 走看看