HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/qas.sports-crowd.com/vendor/react/event-loop/examples/12-generate-yes.php
<?php

use React\EventLoop\Loop;

require __DIR__ . '/../vendor/autoload.php';

// data can be given as first argument or defaults to "y"
$data = (isset($argv[1]) ? $argv[1] : 'y') . "\n";

// repeat data X times in order to fill around 200 KB
$data = str_repeat($data, round(200000 / strlen($data)));

if (!defined('STDOUT') || stream_set_blocking(STDOUT, false) !== true) {
    fwrite(STDERR, 'ERROR: Unable to set STDOUT non-blocking (not CLI or Windows?)' . PHP_EOL);
    exit(1);
}

// write data to STDOUT whenever its write buffer accepts data
// for illustrations purpose only, should use react/stream instead
Loop::addWriteStream(STDOUT, function ($stdout) use (&$data) {
    // try to write data
    $r = fwrite($stdout, $data);

    // nothing could be written despite being writable => closed
    if ($r === 0) {
        Loop::removeWriteStream($stdout);
        fclose($stdout);
        stream_set_blocking($stdout, true);
        fwrite(STDERR, 'Stopped because STDOUT closed' . PHP_EOL);

        return;
    }

    // implement a very simple ring buffer, unless everything has been written at once:
    // everything written in this iteration will be appended for next iteration
    if (isset($data[$r])) {
        $data = substr($data, $r) . substr($data, 0, $r);
    }
});