Let PHP support Yar.packager, can achieve the effect of text highlighting _php tutorial

Source: Internet
Author: User
1. Installation of Msgpack, Yar, yaf three PHP extensions

2, compile Yar, use./configure--enable-msgpack--with-php-config=/usr/local/php/bin/pgp-config parameters,-- The Enable-msgpack parameter is to turn on packager support for Yar

3, Php-i|grep Msgpack, if there is Yar.packager = Msgpack = Msgpack The Yar has supported Msgpack

4. Test page
Class Yarcheckkeyword {
protected static $HOSTNAME = ' kwdt.yarc.service.weibo.com ';
protected static $PORT = ' 7002 ';
/**
*
* Request KWDT Server
*
* @param string $text text strings
*
* @param array $types keyword type
*
* @param int $return _text whether to return hit keyword 1. Yes 0. No, no, no, no.
*
* @return Array
*
*/
Public Function Connectkwdt_server ($text, $return _text = 1, $types =array (1, 2, 3), $withoutsass = False) {
if (!class_exists ("Yar_client") | |! $text | |! $types) {
Return "Yar_client no exists\n";
}
$funcname = "Detect";
$host = Yarcheckkeyword:: $HOSTNAME;
$port = Yarcheckkeyword:: $PORT;
try{
$client = new Yar_client ("tcp://$host: $port");
$response = $client $funcname ($text, $return _text, $types);
return $response;
}catch (Exception $e) {
Print_r ($e);
}
}
}
$text = ' aaaaaaaaaaa ';
$obj =new Yarcheckkeyword ();
$a = $obj->connectkwdt_server ($text);
Print_r ($a);

5, the above code saved as a file, using PHP execution, test results for the following description of success
Array
(
[0] =-1
[1] = no keyword occured
)



http://www.bkjia.com/PHPjc/760154.html www.bkjia.com true http://www.bkjia.com/PHPjc/760154.html techarticle 1, install Msgpack, Yar, yaf three PHP extension 2, compile Yar, use./configure--enable-msgpack--with-php-config=/usr/local/php/bin/ Pgp-config parameter,--enable-msgpack parameter ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.