zoukankan      html  css  js  c++  java
  • php异步处理

    a.php

    <?php
    header("Content-type: text/html; charset=utf-8");
    date_default_timezone_set("Asia/Shanghai");

    $start = microtime(true);

    function fsockopen_get($domain, $url)
    {
    $fp = fsockopen($domain, 80, $errno, $errstr, 30);
    if (!$fp) {
    echo "$errstr ($errno)<br /> ";
    } else {
    $out = "GET " . $url . " / HTTP/1.1 ";
    $out .= "Host: " . $domain . " ";
    $out .= "Connection: Close ";
    fwrite($fp, $out);
    /*忽略执行结果
    while (!feof($fp)) {
    echo fgets($fp, 128);
    }*/
    fclose($fp);
    }
    }
    fsockopen_get('temp.com', '/b.php');

    $end = microtime(true);

    $time= $end - $start;

    //精确到十位小数,可自行调节
    echo number_format($time, 10, '.', '')." seconds";


    b.php
    <?php
    header("Content-type: text/html; charset=utf-8");

    file_put_contents('54321.log', microtime(true), FILE_APPEND);

    sleep(20);

    file_put_contents('54321.log', microtime(true), FILE_APPEND);

  • 相关阅读:
    计算机导论课后总结第二弹
    深入懂得信息
    计算机导论课后总结第一弹
    upload-labs脑图
    高精度学习
    洛谷学习
    Bugku 密码学脑图
    Bypass disabled_functions
    Python库学习
    LFI-labs
  • 原文地址:https://www.cnblogs.com/WebLinuxStudy/p/12220975.html
Copyright © 2011-2022 走看看