PHP 上下文引數
簡介
上下文引數允許自定義對檔案系統和其他流包裝器的訪問。要配置流,PHP 有 **stream_context_set_params()** 函式。
語法
stream_context_set_params ( resource $stream_or_context , array $params ) : bool
$stream_or_context 可以是 PHP 支援的任何流/包裝器/上下文
$params 是一個包含以下屬性的陣列。應為一個結構與陣列關聯的陣列 − $params['paramname'] = "paramvalue";
上下文引數
通知 − 一個使用者定義的回撥,當流觸發一個通知時被呼叫。僅適用於 http:// 和 ftp:// 流包裝器。
通知回撥函式具有以下語法
語法
stream_notification_callback ( int $notification_code , int $severity , string $message , int $message_code , int $bytes_transferred , int $bytes_max ) : void
選項 − 與正在使用的上下文/包裝器對應的受支援選項的陣列
示例
<?php
$ctx = stream_context_create();
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
file_get_contents("https://php.net.tw/contact", false, $ctx);
?>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP