OB in PHP

Source: Internet
Author: User

This article mainly introduces the PHP Ob_start and other functions to intercept the standard output of the relevant data, the need for friends can refer to the

Recently in the use of PHP under the CLI to develop a software, encountered such a problem. I wanted to collect the output from the PHP script, so I used the Ob_start and Ob_end_flush functions, and I did have the function of collecting output, but I also printed it into the console interface. What I want to ask is there is no way to block PHP like the console output information. The software is not allowed to print anything to the console in principle.

PHP-CLI itself from the Web server to execute the script, I do not know how you have access to the data is how to get it? If you do not get it by executing the value returned by the PHP program via the CLI, you can use the Ob_get_clean ()

He'll get the cached content and clear the buffer so that you can achieve what you say does not appear to the display interface

Of course you can also get the buffer content, then empty (control not output to the console), and then falsh the content to the Web server for processing

It's done in accordance with the above method. Before the function of this series has been used, too long not to, some forget.

Now doing is a PHP based multi-process HTTP dynamic server. Graduation thesis, test product, nothing practical.

PHP-CGI program execution result is the standard input output, so can only use to obtain the standard input output way to intercept the output result, the pipeline should also be possible, but I will not

The above mentioned is the entire content of this article, I hope you can enjoy.

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.