略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Stream Contexts

2024-12-22

Stream Contexts

A context is a set of parameters and wrapper specific options which modify or enhance the behavior of a stream. Contexts are created using stream_context_create() and can be passed to most filesystem related stream creation functions (i.e. fopen(), file(), file_get_contents(), etc...).

Options can be specified when calling stream_context_create(), or later using stream_context_set_option(). A list of wrapper specific options can be found in the 上下文(Context)选项和参数 chapter.

Parameters can be specified for contexts using the stream_context_set_params() function.

add a noteadd a note

User Contributed Notes 1 note

up
17
alvaro at demogracia dot com
6 years ago
Two important terms:

- An *option* is a protocol-specific setting, e.g. "method" (get, post, put...) if you are using HTTP or "callback function to be called when inserting a document" in MongoDB.

- A *parameter* is a settings that's common to all protocols. As of 2015 only one parameter got implemented ("notification").

While these words might look vague they are used coherently throughout the stream feature, documentation included.

官方地址:https://www.php.net/manual/en/stream.contexts.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3