IT. Expert System.

PHP

Examples


Examples

Example #1 polling STDIN using basic API

<?php

function print_line($fd$events$arg)
{
    static 
$max_requests 0;

    
$max_requests++;

    if (
$max_requests == 10) {
        
// exit loop after 10 writes
        
event_base_loopexit($arg[1]);
    }

    
// print the line
    
echo  fgets($fd);
}

// create base and event
$base event_base_new();
$event event_new();

$fd STDIN;

// set event flags
event_set($event$fdEV_READ EV_PERSIST"print_line", array($event$base));
// set event base
event_base_set($event$base);

// enable event
event_add($event);
// start event loop
event_base_loop($base);

?>

Example #2 polling STDIN using buffered event API

<?php

function print_line($buf$arg)
{
    static 
$max_requests;

    
$max_requests++;

    if (
$max_requests == 10) {
        
event_base_loopexit($arg);
    }

    
// print the line
    
echo event_buffer_read($buf4096);
}

function 
error_func($buf$what$arg)
{
    
// handle errors
}

$base event_base_new();
$eb event_buffer_new(STDIN"print_line"NULL"error_func"$base);

event_buffer_base_set($eb$base);
event_buffer_enable($ebEV_READ);

event_base_loop($base);

?>



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2233 / 158697384. Delta: 0.02428 с