We know that today’s WEB program development technology is full of contention, but no matter how WEB technology develops in the future, the basic communication protocol for WEB program quality inspection is very important. Today I will introduce to you the WEB application. Inner Workings
PHP comes with many built-in URL-style wrapper protocols for file systems# like fopen(), copy(), file_exists() and filesize() ##function. In addition to these packaging protocols, custom packaging protocols can also be registered through stream_wrapper_register().
file:// — Access local file system
http:// —Access HTTP(s) URLftp:// — Access FTP(s) URLsphp:// — Access individual input/output streams (I/O streams) zlib:// — Compressed streams data:// — Data (RFC 2397) glob:// — Finds matching file path pattern
phar:// — PHP Archive
ssh2:// — Secure Shell 2rar:// — RARogg:// — Audio Streamingexpect:// - Process interactive streams
PHP.iniallow_url_fopen: on By default, this option is turned on to activate the fopen encapsulation protocol in the form of a URL, making it accessible URL object files, etc. allow_url_include: off is turned off by default. If this option is on, it allows the inclusion of URL object files, etc. file:// protocol file:// — access the local file system , not affected by allow_url_fopen and allow_url_includehttp://127.0.0.1/code/1.php?file=file:///E:\phpStudy\WWW\code\phpinfo.php
There is no need to enable allow_url_fopen, only php://input, php://stdin, php://memory and php://temp need to enable allow_url_include. php://stdin, php://stdout and php://stderrphp://stdin, php://stdout and php://stderr allow direct access to PHP The corresponding input or output stream of the process. php://stdin is read-only, php://stdout and php://stderr are write-only. php://stdin
<?php while($line = fopen('php://stdin','r')) {//open our file pointer to read from stdin echo $line."\n"; echo fgets($line);//读取
<?php $fd = fopen('php://stdout', 'w'); if ($fd) { echo $fd."\n"; fwrite($fd, "test"); fwrite($fd, "\n"); fclose($fd); } ?>
<?php $stderr = fopen( 'php://stderr', 'w' ); echo $stderr."\n"; fwrite($stderr, "uknow" ); fclose($stderr); ?>
file_get_contents(), where there is no opportunity to apply additional filters before the data stream contents are read.
<?php include($_GET['file']) ?>
PHP large traffic optimization?
PHP product flash sale timing implementation (solution to large traffic)
How PHP solves the problem of large website traffic and high concurrency
The above is the detailed content of Detailed explanation of php protocol. For more information, please follow other related articles on the PHP Chinese website!