尊龙凯时人生就是博

SwooleʵÏָ߲¢·¢»á¼ûµÄwget

ÔÚ»¥ÁªÍøʱ´ú£¬¾­³£»áÓöµ½ÐèÒª»á¼û´ó×ÚurlµÄ³¡¾°£¬ÈçÅÀ³æ¡¢Êý¾ÝÊÕÂ޵ȡ£¹Å°åµÄwget»òcurl¹¤¾ßÔÚ¾ÙÐи߲¢·¢»á¼ûʱ£¬ºÜÈÝÒ×·ºÆðÆ¿¾±ÒÔ¼°ÐÔÄÜÎÊÌâ¡£¶øswoole£¬×÷ΪphpµÄÀ©Õ¹Ä £¿é£¬¿ÉÒÔΪÎÒÃÇÌṩһ¸ö¸ßЧµÄÌæ»»¼Æ»®¡£

SwooleÊÇÒ»¸ö¿ªÔ´µÄPHPÀ©Õ¹£¬Æä×î³õµÄÉè¼ÆÄ¿µÄÊÇÓÃÓÚ¹¹½¨¸ßÐÔÄÜ¡¢¸ß¿ÉÉìËõÐÔµÄÍøÂçЧÀÍÆ÷ºÍWebЧÀÍ¡£Ëæ×ÅÆäÒ»Ö±µÄÍêÉƺÍÉú³¤£¬SwooleÏÖÔÚÒѾ­³ÉΪÁËPHP¿ª·¢ÖÐÖ÷ÒªµÄÒ»²¿·Ö£¬ÎªÎÒÃÇÌṩÁËÐí¶àÓÅÒìµÄÌØÕ÷ºÍ¹¤¾ß¡£ÆäÖУ¬ÆäÌṩµÄÒì²½·ÇÛÕ±ÕI/OÄ£×Ó£¬Ê¹µÃÔڸ߲¢·¢»á¼û³¡¾°Ï£¬PHPÓ¦ÓñÈÒÔÍùÔ½·¢¸ßЧ¡£

ÄÇô£¬ÔõÑùʹÓÃSwooleʵÏָ߲¢·¢»á¼ûµÄwget¹¤¾ßÄØ £¿ÎÒÃÇ¿ÉÒÔÏȼòÆÓÏàʶÒÔÍù¹Å°åwget¹¤¾ßµÄÔ­Àí£ºwgetÌᳫһ´ÎHTTPÇëÇó£¬È»ºóÆÚ´ýЧÀÍÆ÷ÏìÓ¦¿¢Êºó²Å¾ÙÐÐÏÂÒ»´ÎÇëÇó¡£ÕâÖÖģʽÎÞÒÉ»áÓÉÓÚÆÚ´ýÏìÓ¦¶øµ¼Ö²¢·¢ÐÔÄÜ×ßÏÂÆ·¡£

¶øÔÚSwooleÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃЭ³ÌµÄÌص㣬½«Ã¿´ÎHTTPÇëÇóת»¯ÎªÒ»¸öЭ³Ì£¬Ð­³ÌÔÚÆÚ´ýÏìÓ¦µÄÀú³ÌÖпÉÒÔ±»¹ÒÆ𣬲»Õ¼ÓÃϵͳ×ÊÔ´£¬ÔÚÏìÓ¦¿¢ÊºóÔÙ»Ö¸´Ö´ÐС£ÕâÑù¿ÉÒÔʵÏָ߲¢·¢µÄHTTPÇëÇ󣬲¢ÇÒÔÚÐÔÄܺÍ×ÊÔ´Õ¼Ó÷½Ã涼¾ßÓÐÓÅÊÆ¡£

ÒÔÏÂÊÇÒ»¶ÎʹÓÃSwooleʵÏָ߲¢·¢»á¼ûµÄwget¹¤¾ßµÄʾÀý´úÂ룺

<?php

$client = new SwooleCoroutineHttpClient('www.example.com', 80);

go(function () use ($client) {
    $client->get('/url_1');
    echo $client->body;
});

go(function () use ($client) {
    $client->get('/url_2');
    echo $client->body;
});

go(function () use ($client) {
    $client->get('/url_3');
    echo $client->body;
});

$client->close();

?>

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇʹÓÃÁËSwooleÌṩµÄCoroutineHttpClientÀ࣬ͨ¹ýŲÓÃgetÒªÁìÌᳫHTTPÇëÇó¡£ÎÒÃÇͬʱ¿ªÆôÁËÈý¸öЭ³Ì£¬»®·Ö¾ÙÐÐÁ˲î±ðURLµÄÇëÇ󣬲¢ÔÚ»ñÈ¡µ½ÏìÓ¦ºóʹÓÃechoÓï¾äÊä³öÏìÓ¦µÄÄÚÈÝ¡£ÔÚ×îºó£¬ÎÒÃÇʹÓÃÁËcloseÒªÁì¹Ø±ÕÁË¿Í»§¶ËÅþÁ¬¡£

»ùÓÚSwooleµÄ¸ß²¢·¢»á¼ûµÄwget¹¤¾ß£¬¿ÉÒÔ´ó´óÌáÉýÎÒÃÇÔÚURL»á¼û·½ÃæµÄЧÂʺÍÐÔÄÜ¡£Ïà±ÈÓڹŰåµÄwgetÒÔ¼°curl¹¤¾ß£¬Æä´¦ÀíÄÜÁ¦ºÍ²¢·¢ÐÔÄܶ¼¾ßÓÐÓÅÊÆ£¬ÇÒ¹ØÓÚPHPÓ¦ÓÃÖд¦Àí¸ß²¢·¢ÇëÇóµÄÓªÒµ³¡¾°£¬Ò²¾ßÓкÜÇ¿µÄÊÊÓÃÐÔ¡£

ÒÔÉϾÍÊÇSwooleʵÏָ߲¢·¢»á¼ûµÄwgetµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ