Why echo doesn't show anything while php is busy

The PHP Echo or Print functions show nothing when php is busy with something (for example, when surfing the Internet with curls or something like that).

Later I discovered that php shows the result when executing your php on the command line:

php myscript.php

But right now I'm not getting any command line exits! Are there any tricks or tweaks for php to display outputs?

+3
source share
2 answers

Most likely, it caches the results (both in PHP and on the web server), and does not send them to the browser. the best suggestion I can give is this piece from my code:

/**
 * Act as a "breakpoint" in the code, forcing everything to be flushed to the browser
 */
function breakpoint() {
    global $debug;
    if ($debug) { // So that it doesn't slow down extracts
        ob_flush();
        flush();
        sleep(.1);
    }
}

A file $debugis if we launch a page in debug mode specific to our site.

, , - ob_flush(), PHP - flush(), , . (: -, ). sleep , .

: http://ca.php.net/manual/en/function.ob-flush.php http://ca.php.net/manual/en/function.flush.php

+6

PHP, -, , . script.

flush(), PHP, -, ...

+3

Source: https://habr.com/ru/post/1740176/


All Articles