現在の位置: ホーム> 関数カテゴリ一覧> stream_context_get_options

stream_context_get_options

リソースフロー/パケット/コンテキストのパラメーターを取得します
名前:stream_context_get_options
カテゴリ:ストリーム
対応言語:php
一言説明:指定されたコンテキストのオプションの配列を返します

関数名:stream_context_get_options()

関数の説明:stream_context_get_options()関数は、指定されたコンテキストのオプションの配列を返します。

適用バージョン:PHP 4> = 4.3.0、PHP 5、PHP 7

使用法:stream_context_get_options(resource $ stream_or_context):array

パラメーター:

  • stream_or_context:必須、ストリームまたはコンテキストを表すリソースハンドル。

戻り値:この関数は、指定されたコンテキストのオプションを含む連想配列を返します。

例:

 // 创建一个上下文$context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => json_encode(['name' => 'John', 'age' => 30]) ] ]); // 获取上下文的选项$options = stream_context_get_options($context); // 输出选项数组print_r($options);

出力:

 Array ( [http] => Array ( [method] => POST [header] => Content-Type: application/json [content] => {"name":"John","age":30} ) )

上記の例では、最初にHTTPリクエストのオプションを含むstream_context_create()関数を使用してコンテキストを作成します。次に、stream_context_get_options()関数を使用して、コンテキストのオプションを取得し、$ options変数に保存します。最後に、print_r()関数を使用して、$ optionsアレイの内容を印刷して、コンテキストのオプションを確認します。

出力の結果では、オプション配列にHTTPキーが含まれており、対応する値は連想配列であり、リクエストメソッド、リクエストヘッダー、リクエストボディコンテンツなどのHTTP要求に関連するオプションが含まれていることがわかります。

類似の関数
  • ユーザー定義のストリームフィルターを登録します stream_filter_register

    stream_filter_register

    ユーザー定義のストリームフィルターを登録
  • ストリームがロックをサポートするかどうかを判断します stream_supports_lock

    stream_supports_lock

    ストリームがロックをサポートするかどうか
  • デフォルトのストリームコンテキストを取得します stream_context_get_default

    stream_context_get_default

    デフォルトのストリームコンテキストを取得
  • リソースフローのためにブロッキングまたはブロッキングモードを設定します stream_set_blocking

    stream_set_blocking

    リソースフローのためにブロッキングまたは
  • ストリームがローカルストリームであるかどうかを確認してください stream_is_local

    stream_is_local

    ストリームがローカルストリームであるかど
  • 特定のストリームでファイルバッファリングを書き込みます stream_set_write_buffer

    stream_set_write_buffer

    特定のストリームでファイルバッファリング
  • 特定のストリーム配列でSelect()システムコールを実行し、tv_secおよびtv_usecで指定されたタイムアウトを使用します stream_select

    stream_select

    特定のストリーム配列でSelect()シ
  • リソースフローブロックサイズを設定します stream_set_chunk_size

    stream_set_chunk_size

    リソースフローブロックサイズを設定します