Home > Backend Development > PHP Tutorial > PHP production environment uses php://stdout for safe and efficient debugging

PHP production environment uses php://stdout for safe and efficient debugging

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:12:18
Original
1451 people have browsed it

There are many ways to debug PHP during development. For production environment debugging, both performance and security must be considered. The following are common methods and their disadvantages:

1. Write a log. Use fopen to open a file and write a log. This method is simple and efficient, but when multiple users access it at the same time, it will cause competition problems, consume disk IO, and the file size is not easy to control;

2. Write the database. This method solves the competition problem, but increases the burden on the database. ;

When I was looking at the new features of the new version of php, php://stdout is built-in support from version 5.6. This is a memory object, and the output is printed directly on the server command line, which is completely invisible to the user;

The following is My test code



My first PHP page

echo "Hello World!";
$fd = fopen('php://stdout', 'w');
if ($fd) {
fwrite($fd, "7777888");
fwrite($fd, "n" );
                                      fclose($fd);
7777888
7777888

7777888

7777888





The above introduces the use of php://stdout for safe and efficient debugging in the PHP production environment, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template